salt.modules.augeas_cfg

Manages configuration files via augeas

NOTE: This state requires the augeas Python module.

salt.modules.augeas_cfg.get(path, value='')

Get a value for a specific augeas path

CLI Example:

salt '*' augeas.get /files/etc/hosts/1/ ipaddr
salt.modules.augeas_cfg.ls(path)

List the direct children of a node

CLI Example:

salt '*' augeas.ls /files/etc/passwd
salt.modules.augeas_cfg.match(path, value='')

Get matches for path expression

CLI Example:

salt '*' augeas.match /files/etc/services/service-name ssh
salt.modules.augeas_cfg.remove(path)

Get matches for path expression

CLI Example:

salt '*' augeas.remove /files/etc/sysctl.conf/net.ipv4.conf.all.log_martians
salt.modules.augeas_cfg.setvalue(*args)

Set a value for a specific augeas path

CLI Example:

salt '*' augeas.setvalue /files/etc/hosts/1/canonical localhost

This will set the first entry in /etc/hosts to localhost

CLI Example:

salt '*' augeas.setvalue /files/etc/hosts/01/ipaddr 192.168.1.1 \
                         /files/etc/hosts/01/canonical test

Adds a new host to /etc/hosts the ip address 192.168.1.1 and hostname test

CLI Example:

salt '*' augeas.setvalue prefix=/files/etc/sudoers/ \
         "spec[user = '%wheel']/user" "%wheel" \
         "spec[user = '%wheel']/host_group/host" 'ALL' \
         "spec[user = '%wheel']/host_group/command[1]" 'ALL' \
         "spec[user = '%wheel']/host_group/command[1]/tag" 'PASSWD' \
         "spec[user = '%wheel']/host_group/command[2]" '/usr/bin/apt-get' \
         "spec[user = '%wheel']/host_group/command[2]/tag" NOPASSWD

Ensures that the following line is present in /etc/sudoers:

%wheel ALL = PASSWD : ALL , NOPASSWD : /usr/bin/apt-get , /usr/bin/aptitude
salt.modules.augeas_cfg.tree(path)

Returns recursively the complete tree of a node

CLI Example:

salt '*' augeas.tree /files/etc/