@@ -6,13 +6,15 @@ mounts:
66 - [ ephemeral0 , / mnt / ephemeral0 ]
77
88users:
9+ % { if contains (tags, " puppet" ) || length (setintersection (tags, bastion_tags)) > 0 ~}
910 - name: tf
1011 system: true
1112 passwd: '* '
1213 no_user_group: true
1314 homedir: / tmp
1415% { if contains (tags, " puppet" ) }
1516 sudo: " ALL = NOPASSWD: /usr/sbin/update_etc_puppetlabs.sh *.zip"
17+ % { endif ~}
1618% { endif ~}
1719 - name: ${sudoer_username}
1820 groups: adm, wheel, systemd- journal
@@ -164,16 +166,26 @@ runcmd:
164166 - test -f /run/cloud-init-failed && echo 'WARNING - some steps cloud-init runcmd failed, listed in /run/cloud-init-failed. Manual fixing and rebooting required. ' | tee /etc/motd || true
165167
166168write_files:
167- # If the ip addresses of the puppet servers are not known in advance, we cannot restrict the ssh connection to them.
168- - content: restrict,%{ if contains(tags, "puppet") }pty%{ else }%{if length(compact(values(puppetservers))) = = length (keys (puppetservers)) }% { for host , ip in puppetservers }permitopen =" ${ ip } :22" % { endfor }% { else }pty % { endif },port-forwarding ,command =" /sbin/nologin" % { endif } ${tf_ssh_public_key}
169- path : / etc/ ssh/ authorized_keys.tf
170- permissions: " 0644"
169+ %{ if contains(tags, "puppet") || length(setintersection(tags, bastion_tags)) > 0 ~}
171170 - content: |
172171 Match User tf
173172 AuthorizedKeysFile /etc/ssh/authorized_keys. %u
174173 AuthenticationMethods publickey
175174 path : /etc/ssh/sshd_config. d /50-authenticationmethods. conf
176175 permissions: "0600"
176+ %{ endif ~}
177+ %{ if contains(tags, "puppet") ~}
178+ - content: restrict,pty ${tf_ssh_public_key}
179+ path : /etc/ssh/authorized_keys. tf
180+ permissions: "0644"
181+ %{ else ~}
182+ %{ if length(setintersection(tags, bastion_tags)) > 0 ~}
183+ # If the ip addresses of the puppet servers are not known in advance, we cannot restrict the ssh connection to them.
184+ - content: restrict,%{if length(compact(values(puppetservers))) = = length (keys (puppetservers)) }% { for host , ip in puppetservers }permitopen =" ${ ip } :22" % { endfor }% { else }pty % { endif },port-forwarding ,command =" /sbin/nologin" ${tf_ssh_public_key}
185+ path : / etc/ ssh/ authorized_keys.tf
186+ permissions: " 0644"
187+ % { endif ~}
188+ % { endif ~}
177189 - content: |
178190 facts : {
179191 blocklist : [
0 commit comments