Automate File Content: copy, template, lineinfile, blockinfile
WebAsha standardises login banners, SSH settings and shared directories across environments. Every file must be managed by a playbook so the next run puts it back if someone edits it by hand.
Tasks
- Create the template ~/ansible/templates/motd.j2 and the playbook ~/ansible/motd.yml so that /etc/motd on every node reads exactly This is <host in the <env environment (e.g. This is node1 in the dev environment, This is node3 in the prod environment).
- Write ~/ansible/issue.yml: on prod only, /etc/issue contains Authorized WebAsha staff only, owner root, mode 0644.
- Write ~/ansible/sshd.yml: on all nodes make sure /etc/ssh/sshdconfig has the line PermitRootLogin no (replacing any existing PermitRootLogin line), validating the file with sshd -t before saving.
- Write ~/ansible/limits.yml: on dev, add this block to /etc/security/limits.conf between the markers BEGIN WEBASHA DEV / END WEBASHA DEV: @developers soft nproc 4096 and @developers hard nproc 8192.
- Write ~/ansible/shared.yml: on dev and test (not prod) create directory /srv/webasha owned by group wheel with mode 2775 (setgid), and a symlink /srv/current pointing to it.