fix role and ansible-lint errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
disable_pam: false
|
sshd_disable_pam: false
|
||||||
password_auth: false
|
sshd_password_auth: false
|
||||||
challenge_response_auth: false
|
sshd_challenge_response_auth: false
|
||||||
gss_api_auth: false
|
sshd_gss_api_auth: false
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: blank
|
- name: Blank
|
||||||
ansible.builtin.command: echo
|
ansible.builtin.command: echo
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
# next task requires this directory to exist for sshd -t flag
|
||||||
|
- name: Ensure /run/sshd exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /run/sshd
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
# NOTE: order of preference for openssh-server ed25519 -> rsa
|
# NOTE: order of preference for openssh-server ed25519 -> rsa
|
||||||
- name: "Algorithms | enable ed25519 authentication algorithm"
|
- name: "Algorithms | enable ed25519 authentication algorithm"
|
||||||
notify: Restart sshd
|
notify: Restart sshd
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
notify: Restart sshd
|
notify: Restart sshd
|
||||||
loop:
|
loop:
|
||||||
- { regexp: '^#?\s*PubkeyAuthentication\s+', line: 'PubkeyAuthentication yes' }
|
- { regexp: '^#?\s*PubkeyAuthentication\s+', line: 'PubkeyAuthentication yes' }
|
||||||
- { regexp: '^#?\s*PasswordAuthentication\s+', line: 'PasswordAuthentication {{ password_auth | ternary("yes", "no") }}' }
|
- { regexp: '^#?\s*PasswordAuthentication\s+', line: 'PasswordAuthentication {{ sshd_password_auth | ternary("yes", "no") }}' }
|
||||||
- { regexp: '^#?\s*PermitEmptyPasswords\s+', line: 'PermitEmptyPasswords no' }
|
- { regexp: '^#?\s*PermitEmptyPasswords\s+', line: 'PermitEmptyPasswords no' }
|
||||||
- { regexp: '^#?\s*ChallengeResponseAuthentication\s+', line: 'ChallengeResponseAuthentication {{ challenge_response_auth | ternary("yes", "no") }}' }
|
- { regexp: '^#?\s*ChallengeResponseAuthentication\s+', line: 'ChallengeResponseAuthentication {{ sshd_challenge_response_auth | ternary("yes", "no") }}' }
|
||||||
- { regexp: '^#?\s*GSSAPIAuthentication\s+', line: 'GSSAPIAuthentication {{ gss_api_auth | ternary("yes", "no") }}' }
|
- { regexp: '^#?\s*GSSAPIAuthentication\s+', line: 'GSSAPIAuthentication {{ sshd_gss_api_auth | ternary("yes", "no") }}' }
|
||||||
- {
|
- {
|
||||||
regexp: '^#?\s*AuthenticationMethods\s+',
|
regexp: '^#?\s*AuthenticationMethods\s+',
|
||||||
line: "{{ 'AuthenticationMethods publickey password' if password_auth else 'AuthenticationMethods publickey' }}"
|
line: "{{ 'AuthenticationMethods publickey password' if sshd_password_auth else 'AuthenticationMethods publickey' }}"
|
||||||
}
|
}
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
@@ -22,10 +22,10 @@
|
|||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
||||||
|
|
||||||
- name: "Authentication | override password authentication by cloud-init to '{{ password_auth | ternary('yes', 'no') }}'"
|
- name: "Authentication | override password authentication by cloud-init to '{{ sshd_password_auth | ternary('yes', 'no') }}'"
|
||||||
when: sshd_cloud_init.stat.exists
|
when: sshd_cloud_init.stat.exists
|
||||||
notify: Restart sshd
|
notify: Restart sshd
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
||||||
regexp: '^#?PasswordAuthentication'
|
regexp: '^#?PasswordAuthentication'
|
||||||
line: 'PasswordAuthentication {{ password_auth | ternary("yes", "no") }}'
|
line: 'PasswordAuthentication {{ sshd_password_auth | ternary("yes", "no") }}'
|
||||||
|
|||||||
@@ -10,3 +10,4 @@
|
|||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: openssh-server
|
name: openssh-server
|
||||||
state: present
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?UsePAM'
|
regexp: '^#?UsePAM'
|
||||||
line: "UsePAM {{ disable_pam | ternary('no', 'yes') }}"
|
line: "UsePAM {{ sshd_disable_pam | ternary('no', 'yes') }}"
|
||||||
validate: sshd -f %s -t
|
validate: sshd -f %s -t
|
||||||
|
|
||||||
- name: "Restrictions | ensure the SSHD config is restricted to the root user"
|
- name: "Restrictions | ensure the SSHD config is restricted to the root user"
|
||||||
|
|||||||
Reference in New Issue
Block a user