diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-01-24 00:33:50 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-01-24 01:03:37 +0100 |
| commit | d7b3463a79a50dc81d28d530c5212a1749efbb15 (patch) | |
| tree | 198f009230b71c23275400826a2f60e50f01360a /roles/ssh | |
| parent | 4b9d5e3318d4de8df862f3794c6bc85eba6f8942 (diff) | |
Fix ansible 2.20.1 deprecation warning about ansible_vars
Diffstat (limited to 'roles/ssh')
| -rw-r--r-- | roles/ssh/handlers/main.yml | 4 | ||||
| -rw-r--r-- | roles/ssh/tasks/main.yml | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/roles/ssh/handlers/main.yml b/roles/ssh/handlers/main.yml index f8760549..d9e025d0 100644 --- a/roles/ssh/handlers/main.yml +++ b/roles/ssh/handlers/main.yml @@ -3,11 +3,11 @@ become: true ansible.builtin.systemd_service: daemon_reload: true - when: not ansible_is_chroot + when: not ansible_facts['is_chroot'] - name: "Restart ssh" become: true ansible.builtin.systemd_service: name: "{{ ssh_service }}" state: "restarted" - when: not ansible_is_chroot + when: not ansible_facts['is_chroot'] diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml index 76ba7aa5..cb798c1e 100644 --- a/roles/ssh/tasks/main.yml +++ b/roles/ssh/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: "Include OS-specific variables" - ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml" + ansible.builtin.include_vars: "{{ ansible_facts['os_family'] | lower }}.yml" - name: "Ensure ssh package is installed" become: true @@ -14,13 +14,13 @@ name: "{{ ssh_service }}" state: "started" enabled: true - when: not ansible_is_chroot + when: not ansible_facts['is_chroot'] - name: "(chroot): Ensure ssh service is enabled" # noqa: command-instead-of-module intentional isnide chroot ansible.builtin.command: cmd: "systemctl enable {{ ssh_service }}" - when: ansible_is_chroot + when: ansible_facts['is_chroot'] changed_when: true - name: "Generate /etc/ssh/ RSA host key" @@ -46,7 +46,7 @@ ansible.builtin.copy: dest: "/etc/ssh/sshd_config" mode: "0640" - validate: "{{ 'sshd -T -f %s' if (not ansible_is_chroot) else omit }}" + validate: "{{ 'sshd -T -f %s' if (not ansible_facts['is_chroot']) else omit }}" content: | KbdInteractiveAuthentication no # default installation is no UsePAM no # default installation is yes @@ -70,7 +70,7 @@ ansible.builtin.copy: dest: "/etc/ssh/sshd_config.d/99-auth-policy.conf" mode: "0640" - validate: "{{ 'sshd -T -f %s' if (not ansible_is_chroot) else omit }}" + validate: "{{ 'sshd -T -f %s' if (not ansible_facts['is_chroot']) else omit }}" content: | Port {{ ssh_port }} PasswordAuthentication no @@ -89,7 +89,7 @@ ansible.builtin.copy: dest: "/etc/ssh/sshd_config.d/99-allowed-users.conf" mode: "0640" - validate: "{{ 'sshd -T -f %s' if (not ansible_is_chroot) else omit }}" + validate: "{{ 'sshd -T -f %s' if (not ansible_facts['is_chroot']) else omit }}" content: | AllowUsers {{ username }} notify: @@ -99,7 +99,7 @@ ansible.builtin.known_hosts: name: "{{ item.split(' ') | first }}" key: "{{ item }}" - path: "{{ ansible_env.HOME }}/.ssh/known_hosts" + path: "{{ ansible_facts['env'].HOME }}/.ssh/known_hosts" state: present loop: "{{ ssh_known_hosts }}" when: ssh_known_hosts is defined and ssh_known_hosts | length > 0 |
