Still play with vars precedence and try backrefs for lineinfile

This commit is contained in:
Bertrand Benjamin 2018-08-24 11:22:07 +02:00
parent 8c7c4d7777
commit fad2dc0217
2 changed files with 10 additions and 7 deletions

View File

@ -2,12 +2,12 @@
- hosts: localhost - hosts: localhost
connection: local connection: local
vars:
- deploy_public_key: files/id_ed25519_home.pub
vars_files: vars_files:
- vars/common.yml - vars/common.yml
extra_vars:
- deploy_public_key: files/id_ed25519_home.pub
tasks: tasks:
- include: tasks/arch_CLI_packages.yml - include: tasks/arch_CLI_packages.yml
- include: tasks/zsh.yml - include: tasks/zsh.yml

View File

@ -1,20 +1,22 @@
--- ---
- name: Copy sshd_config # - name: Copy sshd_config
template: # template:
src: files/sshd_config # src: files/sshd_config
dest: /etc/ssh/sshd_config # dest: /etc/ssh/sshd_config
- name: Disable empty password login - name: Disable empty password login
lineinfile: lineinfile:
dest: /etc/ssh/sshd_config dest: /etc/ssh/sshd_config
regexp: "^#?PermitEmptyPasswords" regexp: "^#?PermitEmptyPasswords"
line: "PermitEmptyPasswords no" line: "PermitEmptyPasswords no"
backrefs: yes
- name: Disable remote root login - name: Disable remote root login
lineinfile: lineinfile:
dest: /etc/ssh/sshd_config dest: /etc/ssh/sshd_config
regexp: "^#?PermitRootLogin" regexp: "^#?PermitRootLogin"
line: "PermitRootLogin no" line: "PermitRootLogin no"
backrefs: yes
- name: debug - name: debug
debug: debug:
@ -33,6 +35,7 @@
dest: /etc/ssh/sshd_config dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication" regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no" line: "PasswordAuthentication no"
backrefs: yes
when: add_identity_key is success and not add_identity_key is skipped when: add_identity_key is success and not add_identity_key is skipped
notify: restart sshd notify: restart sshd