Re: [EXTERNAL] Re: Equivalent of macros functionality with salt registered system?
Thanks. Sigh. That's is a lot further off into the weeds than I wanted to get, but I can probably make something work. My usage for SUSE Manager and Uyuni is about 50% patching, 40% pushing config files, and 10% remote execution. I really haven't gotten into the Salt states, because until I started finding that macros don't work, I haven't had much need to change my process from the original way I've been doing things forerver (pre-salt). Postfix was the example I gave, but I've been using salt postfix.set_main to set relayhost and the hostname. What I'm trying to do is to deploy an rpm-based agent to about 500 clients, then push the config file, having the hostname populated. With this, I can figure out enough of salt to do a salt state to put the agent out there, then do what you suggested with the file replace, or push it as I had planned, and remote execute something to use sed in a shell script to do it. Or, I can remote execute a shell script to do the whole thing. Allen B. -- Allen Beddingfield Systems Engineer Office of Information Technology The University of Alabama Office 205-348-2251 allen@ua.edu <https://www.ua.edu/> ________________________________ From: Julio Gonzalez Sent: Friday, May 28, 2021 4:52 PM To: uyuni-users@opensuse.org; users@lists.uyuni-project.org Cc: Allen Beddingfield Subject: [EXTERNAL] Re: Equivalent of macros functionality with salt registered system? On viernes, 28 de mayo de 2021 21:48:28 (CEST) Allen Beddingfield wrote:
Is there an equivalent of the Spacewalk macros that work with traditional clients for systems registered with salt?
For example, here is what I used to put in the /etc/postfix/main.cf config file: myhostname = {| rhn.system.hostname |}
When the client is registered with salt, it puts that string of text, instead of putting the value of the hostname. How can I accomplish this with a salt client?
Here is a link to the functionality I mention. https://access.redhat.com/documentation/en-us/red_hat_satellite/5.6/html/get ting_started_guide/getting_started_guide-channel_management-managing_configu ration_channels-including_macros_in_configuration_files
You use grains, and can use pillar data, depend on what you need. https://www.uyuni-project.org/uyuni-docs/uyuni/salt/salt-states.html https://docs.saltproject.io/en/3002/topics/grains/ https://docs.saltproject.io/en/3002/topics/pillar/index.html And since 2021.05 you can have also any custom data as pillar data, that then you can use at the salt states: https://www.uyuni-project.org/doc/2021.05/release-notes-uyuni-server.html#_c... For your example, if you only want to change a single line, you could use file.replace as part of a state https://docs.saltproject.io/en/latest/ref/states/all/salt.states.file.html#s... mystate: file.replace: - name: /etc/postfix/main.cf - pattern: 'myhostname = .*' - repl: 'myhostname = '"{{salt['grains.get']('fqdn')}}"' But as I guess you want to change more things at that postfix configuration, then you should consider "file.managed" and jinja templates: https://docs.saltproject.io/en/3002/topics/jinja/index.html#jinja-in-files Hope it helps :-)
Thanks! Allen B. -- Allen Beddingfield Systems Engineer Office of Information Technology The University of Alabama Office 205-348-2251 allen@ua.edu
-- Julio González Gil Release Engineer, SUSE Manager and Uyuni jgonzalez@suse.com
participants (1)
-
Allen Beddingfield