Библиотека ansible плейбуков на разные случаи
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.yml 651B

123456789101112131415161718192021222324252627
  1. ---
  2. - name: Remove all marked options from config
  3. become: yes
  4. lineinfile:
  5. path: "{{ sshd_config_path }}"
  6. state: absent
  7. regexp: '{{ item.key }}'
  8. with_dict: "{{ sshd_options }}"
  9. when: sshd_options != None and sshd_options is defined
  10. # Nice, now add options from ansible configs
  11. - name: Add marked options to config
  12. become: yes
  13. lineinfile:
  14. path: "{{ sshd_config_path }}"
  15. state: present
  16. line: '{{ item.key }} {{ item.value }}'
  17. with_dict: "{{ sshd_options }}"
  18. when: sshd_options != None and sshd_options is defined
  19. # Ok, applying new options
  20. - name: Restart ssh
  21. become: yes
  22. service: name=ssh state=restarted