Browse Source

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

Vladimir Smagin 2 months 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 @@
1 1
 ---
2 2
 
3
-- name: Set PubkeyAuthentication = yes
3
+- name: Remove all marked options from config
4 4
   become: yes
5 5
   lineinfile:
6
-    path: /etc/ssh/sshd_config
7
-    regexp: '^PubkeyAuthentication no'
8
-    line: 'PubkeyAuthentication yes'
6
+    path: "{{ sshd_config_path }}"
7
+    state: absent
8
+    regexp: '{{ item.key }}'
9
+  with_dict: "{{ sshd_options }}"
10
+  when: sshd_options != None and sshd_options is defined
9 11
 
10
-- name: Set PasswordAuthentication = no
12
+# Nice, now add options from ansible configs
13
+
14
+- name: Add marked options to config
11 15
   become: yes
12 16
   lineinfile:
13
-    path: /etc/ssh/sshd_config
14
-    regexp: '^PasswordAuthentication yes'
15
-    line: 'PasswordAuthentication no'
17
+    path: "{{ sshd_config_path }}"
18
+    state: present
19
+    line: '{{ item.key }} {{ item.value }}'
20
+  with_dict: "{{ sshd_options }}"
21
+  when: sshd_options != None and sshd_options is defined
22
+
23
+# Ok, applying new options
16 24
 
17 25
 - name: Restart ssh
18 26
   become: yes
19
-  service: name=ssh state=restarted
20
-
27
+  service: name=ssh state=restarted

Loading…
Cancel
Save