Equivalent of macros functionality with salt registered system?
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... Thanks! Allen B. -- Allen Beddingfield Systems Engineer Office of Information Technology The University of Alabama Office 205-348-2251 allen@ua.edu
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 (2)
-
Allen Beddingfield
-
Julio Gonzalez