ci: Fix sshd configuration during image prep

This will allow image preparation using Ansible versions that
- predate ansible_facts.*
- predate loop keyword
- predate collections
pull/1252/head
Alex Willmer 9 months ago
parent 20e23b5bd9
commit f2e0e552ac

@ -32,6 +32,7 @@
roles:
- role: sshd
- role: sshd_container
tasks:
- name: Ensure requisite apt packages are installed

@ -62,7 +62,7 @@
- name: Create Mitogen test groups
group:
name: "{{ item.name }}"
loop: "{{ mitogen_test_groups }}"
with_items: "{{ mitogen_test_groups }}"
- name: Create user accounts
vars:
@ -158,7 +158,6 @@
Defaults>mitogen__pw_required targetpw
Defaults>mitogen__require_tty requiretty
Defaults>mitogen__require_tty_pw_required requiretty,targetpw
prepend_newline: true
validate: '/usr/sbin/visudo -cf %s'
- name: Configure sudoers users
@ -174,7 +173,6 @@
{% for runas_user in normal_users %}
{{ lookup('pipe', 'whoami') }} ALL = ({{ runas_user.name }}:ALL) NOPASSWD:ALL
{% endfor %}
prepend_newline: true
validate: '/usr/sbin/visudo -cf %s'
when:
- ansible_virtualization_type != "docker"

@ -5,3 +5,4 @@
become: true
roles:
- role: sshd
- role: sshd_macos

@ -9,23 +9,12 @@
path: "{{ sshd_config_file }}"
line: "{{ item.line }}"
regexp: "{{ item.regexp }}"
loop:
with_items:
- line: Banner /etc/ssh/banner.txt
regexp: '^#? *Banner.*'
- line: MaxAuthTries {{ sshd_config__max_auth_tries }}
regexp: '^#? *MaxAuthTries.*'
- line: PermitRootLogin yes
regexp: '.*PermitRootLogin.*'
loop_control:
label: "{{ item.line }}"
register: configure_sshd_result
- name: Restart sshd
shell: |
launchctl unload /System/Library/LaunchDaemons/ssh.plist
wait 5
launchctl load -w /System/Library/LaunchDaemons/ssh.plist
changed_when: true
when:
- ansible_facts.distribution == "MacOSX"
- configure_sshd_result is changed
notify:
- Restart sshd # Handler in platform specific role

@ -0,0 +1,2 @@
- name: Restart sshd
meta: noop

@ -0,0 +1,6 @@
- name: Restart sshd
shell: |
launchctl unload /System/Library/LaunchDaemons/ssh.plist
wait 5
launchctl load -w /System/Library/LaunchDaemons/ssh.plist
changed_when: true
Loading…
Cancel
Save