Skip to content

Instantly share code, notes, and snippets.

@catvec
Last active January 29, 2019 21:06
Show Gist options
  • Select an option

  • Save catvec/52e6641a7547aef7951be297689b6cca to your computer and use it in GitHub Desktop.

Select an option

Save catvec/52e6641a7547aef7951be297689b6cca to your computer and use it in GitHub Desktop.
Salt sshd restart state
{% set file = '/etc/ssh/sshd_config' %}
{{ file }}:
file.managed:
- source: salt://sshd-config/sshd_config
- mode: 664
sshd:
service.running:
- reload: True
- watch:
- file: {{ file }}
[DEBUG ] Could not find file 'salt://sshd-config.sls' in saltenv 'base'
[DEBUG ] In saltenv 'base', looking at rel_path 'sshd-config/init.sls' to resolve 'salt://sshd-confi$
/init.sls'
[DEBUG ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/files/base/sshd-config/in$
t.sls' to resolve 'salt://sshd-config/init.sls'
[DEBUG ] compile template: /var/cache/salt/minion/files/base/sshd-config/init.sls
[DEBUG ] Jinja search path: [u'/var/cache/salt/minion/files/base']
[DEBUG ] LazyLoaded roots.envs
[DEBUG ] Could not LazyLoad roots.init: 'roots.init' is not available.
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/sshd-config/init.sls' using $
jinja' renderer: 0.0244920253754
[DEBUG ] Rendered data from file: /var/cache/salt/minion/files/base/sshd-config/init.sls:
/etc/ssh/sshd_config:
file.managed:
- source: salt://sshd-config/sshd_config
- mode: 644
sshd:
service.running:
- watch:
- file: /etc/ssh/sshd_config
[DEBUG ] Results of YAML rendering:
OrderedDict([(u'/etc/ssh/sshd_config', OrderedDict([(u'file.managed', [OrderedDict([(u'source', u'salt$
//sshd-config/sshd_config')]), OrderedDict([(u'mode', 644)])])])), (u'sshd', OrderedDict([(u'service.ru
nning', [OrderedDict([(u'watch', [OrderedDict([(u'file', u'/etc/ssh/sshd_config')])])])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/sshd-config/init.sls' using '
yaml' renderer: 0.00308585166931
.................
[INFO ] Running state [/etc/ssh/sshd_config] at time 21:05:42.152165
[INFO ] Executing state file.managed for [/etc/ssh/sshd_config]
[DEBUG ] LazyLoaded roots.envs
[DEBUG ] Could not LazyLoad roots.init: 'roots.init' is not available.
[DEBUG ] In saltenv 'base', looking at rel_path 'sshd-config/sshd_config' to resolve 'salt://sshd-con
fig/sshd_config'
[DEBUG ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/files/base/sshd-config/ssh
d_config' to resolve 'salt://sshd-config/sshd_config'
[DEBUG ] LazyLoaded files.is_text
[DEBUG ] LazyLoaded stringutils.get_diff
[INFO ] The file /etc/ssh/sshd_config is set to be changed
[INFO ] Completed state [/etc/ssh/sshd_config] at time 21:05:42.184489 (duration_in_ms=32.325)
[INFO ] Running state [sshd] at time 21:05:42.185421
[INFO ] Executing state service.running for [sshd]
[INFO ] Executing command 'sv status /var/service/sshd' in directory '/root'
[DEBUG ] stdout: run: /var/service/sshd: (pid 608) 163528s
[INFO ] The service sshd is already running
[INFO ] Completed state [sshd] at time 21:05:42.193320 (duration_in_ms=7.899)
----------
ID: /etc/ssh/sshd_config
Function: file.managed
Result: None
Comment: The file /etc/ssh/sshd_config is set to be changed
Started: 20:32:15.347847
Duration: 33.767 ms
Changes:
----------
diff:
---
+++
@@ -29,7 +29,7 @@
# Authentication:
#LoginGraceTime 2m
-PermitRootLogin yes
+PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
----------
ID: sshd
Function: service.running
Result: True
Comment: The service sshd is already running
Started: 20:32:15.382397
Duration: 6.703 ms
Changes:
----------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment