Browse Source

Изменить 'roles/sshd/tasks/main.yml'

pubkey_sshd
Vladimir Smagin 1 year ago
parent
commit
3b0a6873fc
1 changed files with 17 additions and 10 deletions
  1. 17
    10
      roles/sshd/tasks/main.yml

+ 17
- 10
roles/sshd/tasks/main.yml View File

@@ -1,20 +1,27 @@
---

- name: Set PubkeyAuthentication = yes
- name: Remove all marked options from config
become: yes
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PubkeyAuthentication no'
line: 'PubkeyAuthentication yes'
path: "{{ sshd_config_path }}"
state: absent
regexp: '{{ item.key }}'
with_dict: "{{ sshd_options }}"
when: sshd_options != None and sshd_options is defined

- name: Set PasswordAuthentication = no
# Nice, now add options from ansible configs

- name: Add marked options to config
become: yes
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PasswordAuthentication yes'
line: 'PasswordAuthentication no'
path: "{{ sshd_config_path }}"
state: present
line: '{{ item.key }} {{ item.value }}'
with_dict: "{{ sshd_options }}"
when: sshd_options != None and sshd_options is defined

# Ok, applying new options

- name: Restart ssh
become: yes
service: name=ssh state=restarted

service: name=ssh state=restarted

Loading…
Cancel
Save