-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hey Laurence,
hmmmmmmm... maybe it will be easier using the augeas.change state [0]
instead of a template for sshd_config then?
The augeas-lens for sshd_config has support for match-sections (see
[1], under "More advanced usage") so one state could set-up the Matches
and another one could set the "PasswordAuthentication no" bit.
Augeas would parse the sshd_config and only check if the bits it's
supposed to check/set are correct so your won't see changes everytime
you call the state.
On most distributions you just have to install `python-augeas` (and
maybe libpython2.7) and restart the minion to enable the module.
Then you could use states like this...:
sshd_config_Matches:
augeas.change:
- context: /files/etc/ssh/sshd_config/
- changes:
- set Match[1]/Condition/User "foo"
- set Match[1]/Settings/X11Forwarding "yes"
...and this:
sshd_config_no_passwd_auth:
augeas.set:
- context: /files/etc/ssh/sshd_config/
- changes:
- set PasswordAuthentication no
Kind Regards, Florian
[0]
http://docs.saltstack.com/en/latest/ref/states/all/salt.states.augeas.html
[1]
http://augeas.net/docs/references/lenses/files/sshd-aug.html
Am 18.09.2014 um 16:04 schrieb laurence:
> Florian,
>
> That's quite neat for that sort of use-case (I'm going to have to
> try that at home!).
>
> I've kinda worked around it by deploying the sshd_config file
> (which is templated, as it has an accumulator for Match sections at
> the end) and then doing a replace in a separate sls for the line we
> want to change (PasswordAuthentication no) but this results in the
> file getting pushed out and then changed on every update. Is there
> a way to set a context variable in another sls and have it
> available in the template (with a required_in)?
>
> Something like this:
>
> --no_password_auth.sls-- sshd_config_no_passwd_auth: context: -
> set - name: password_auth - value: 'no' - required_in: - file:
> sshd_config
>
> --sshd_config.sls-- sshd_config: file: - managed - name:
> /etc/ssh/sshd_config - source: salt://some/path/sshd_config.j2 -
> template: jinja - default: password_auth: 'yes'
>
> --sshd_config.j2-- ... PasswordAuthentication {{ password_auth }}
> ...
>
>
> Laurence
>
> On 2014-09-18 14:25, Florian Ermisch wrote: Hi Laurence,
iQEcBAEBCgAGBQJUHB2RAAoJECgjvD+8219lHgAIAIKu29VhLHTxKNnz6vtDXfPM
rysMn+wHlXAWxYNZnm9wZ5S0XVxaE84eR+5s5/zsBJ4H/eJX/Zeyv2Wjwk0p2AEL
ATXsY42Zn+/8GyoGsUjKTvGanV3rVvUiBIMTYf1MfNtlkRyZuLw08+6wBWXeI447
xB4iTXtFMBlYhvDlET3GD6KaIj+W9WqbAFPtMeLtck9wCQnKeM02Qbi3LMPzabna
OrhXSTqyZaxQDYmnkVX8elnmwkWZRrFRwtZbymKDMLk6+onVj+t/MVB7lmUcruKL
qonC+vkZcwwKjrx3wR/wj09GV9iqvPAuEXOEFGdh+QfFbeEXhMHR3wvlcqJjg9I=
=hA3z
-----END PGP SIGNATURE-----