move roles, files and templates dirs out of playbook dir into root dir
Because of how Ansible local relative search paths work, the global "files" and "templates" directories need to be next to the playbooks. However its not intuitive to look into the "playbooks" directory to find the files and templates for a host. Therefore move them out of the "playbooks" directory into the root directory and add symlinks so everything still works. Similarly for local roles, they also need to be next to the playbooks. So for a nicer structure, move the "roles" directory out into the root directory as well and add a symlink so everything still works. Also see: https://docs.ansible.com/ansible/latest/playbook_guide/playbook_pathing.html#resolving-local-relative-paths https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#storing-and-finding-roles
This commit is contained in:
parent
2460c31e78
commit
f16f8697c2
147 changed files with 3 additions and 0 deletions
roles/deploy_ssh_server_config/tasks
36
roles/deploy_ssh_server_config/tasks/main.yaml
Normal file
36
roles/deploy_ssh_server_config/tasks/main.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Role and config created after: https://infosec.mozilla.org/guidelines/openssh
|
||||
- name: deploy SSH server config
|
||||
become: true
|
||||
|
||||
block:
|
||||
- name: deploy `sshd_config`
|
||||
ansible.builtin.template:
|
||||
force: true
|
||||
dest: /etc/ssh/sshd_config
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
src: sshd_config.j2
|
||||
notify:
|
||||
# Reboot instead of just restarting the ssh service, since I don't know how Ansible reacts, when it restarts the service it probably needs for the connection.
|
||||
- reboot the system
|
||||
|
||||
- name: deactivate short moduli
|
||||
ansible.builtin.shell:
|
||||
executable: /bin/bash
|
||||
cmd: |
|
||||
set -eo pipefail
|
||||
|
||||
awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.tmp
|
||||
if diff /etc/ssh/moduli /etc/ssh/moduli.tmp; then
|
||||
rm /etc/ssh/moduli.tmp
|
||||
else
|
||||
mv /etc/ssh/moduli.tmp /etc/ssh/moduli
|
||||
echo "ansible-changed: changed /etc/ssh/moduli"
|
||||
fi
|
||||
register: result
|
||||
changed_when:
|
||||
- '"ansible-changed" in result.stdout'
|
||||
notify:
|
||||
# Reboot instead of just restarting the ssh service, since I don't know how Ansible reacts, when it restarts the service it probably needs for the connection.
|
||||
- reboot the system
|
Loading…
Add table
Add a link
Reference in a new issue