fix role and ansible-lint errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
disable_pam: false
|
||||
password_auth: false
|
||||
challenge_response_auth: false
|
||||
gss_api_auth: false
|
||||
sshd_disable_pam: false
|
||||
sshd_password_auth: false
|
||||
sshd_challenge_response_auth: false
|
||||
sshd_gss_api_auth: false
|
||||
|
||||
@@ -10,8 +10,8 @@ galaxy_info:
|
||||
|
||||
platforms:
|
||||
- name: "Ubuntu"
|
||||
versions: [ "focal", "jammy" ]
|
||||
versions: ["focal", "jammy"]
|
||||
|
||||
galaxy_tags: [ ]
|
||||
galaxy_tags: []
|
||||
|
||||
dependencies: []
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
- name: blank
|
||||
- name: Blank
|
||||
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
|
||||
- name: "Algorithms | enable ed25519 authentication algorithm"
|
||||
notify: Restart sshd
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
notify: Restart sshd
|
||||
loop:
|
||||
- { 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*ChallengeResponseAuthentication\s+', line: 'ChallengeResponseAuthentication {{ challenge_response_auth | ternary("yes", "no") }}' }
|
||||
- { regexp: '^#?\s*GSSAPIAuthentication\s+', line: 'GSSAPIAuthentication {{ gss_api_auth | ternary("yes", "no") }}' }
|
||||
- { regexp: '^#?\s*ChallengeResponseAuthentication\s+', line: 'ChallengeResponseAuthentication {{ sshd_challenge_response_auth | ternary("yes", "no") }}' }
|
||||
- { regexp: '^#?\s*GSSAPIAuthentication\s+', line: 'GSSAPIAuthentication {{ sshd_gss_api_auth | ternary("yes", "no") }}' }
|
||||
- {
|
||||
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:
|
||||
path: /etc/ssh/sshd_config
|
||||
@@ -22,10 +22,10 @@
|
||||
ansible.builtin.stat:
|
||||
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
|
||||
notify: Restart sshd
|
||||
ansible.builtin.lineinfile:
|
||||
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
||||
regexp: '^#?PasswordAuthentication'
|
||||
line: 'PasswordAuthentication {{ password_auth | ternary("yes", "no") }}'
|
||||
line: 'PasswordAuthentication {{ sshd_password_auth | ternary("yes", "no") }}'
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
ansible.builtin.apt:
|
||||
name: openssh-server
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^#?UsePAM'
|
||||
line: "UsePAM {{ disable_pam | ternary('no', 'yes') }}"
|
||||
line: "UsePAM {{ sshd_disable_pam | ternary('no', 'yes') }}"
|
||||
validate: sshd -f %s -t
|
||||
|
||||
- name: "Restrictions | ensure the SSHD config is restricted to the root user"
|
||||
|
||||
Reference in New Issue
Block a user