aboutsummaryrefslogtreecommitdiffstats
path: root/roles/common/tasks
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2022-01-10 16:06:00 +0000
committerGravatar Joe Banks <[email protected]>2022-01-10 16:06:00 +0000
commitd9c1fd917431a5b65a0f4d987abc67331e2b37ee (patch)
treedd2c3b1315933897756671c0610acfc310b5f112 /roles/common/tasks
parentAdd Ansible inventory (diff)
Add common role for configuring hostnames and SSH
Diffstat (limited to 'roles/common/tasks')
-rw-r--r--roles/common/tasks/main.yml29
1 files changed, 29 insertions, 0 deletions
diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml
new file mode 100644
index 0000000..a83bac5
--- /dev/null
+++ b/roles/common/tasks/main.yml
@@ -0,0 +1,29 @@
+- name: Update hostname to match Ansible inventory
+ hostname:
+ name: "{{ inventory_hostname }}"
+
+- name: Update /etc/hosts to match Ansible inventory
+ template:
+ src: etc-hosts.j2
+ dest: /etc/hosts
+ mode: '0644'
+ owner: root
+ group: root
+
+- name: Disable SSH password authentication
+ lineinfile:
+ dest: /etc/ssh/sshd_config
+ regexp: "^PasswordAuthentication"
+ line: "PasswordAuthentication no"
+ state: present
+ notify:
+ - restart ssh
+
+- name: Set timezone to UTC
+ file:
+ src: /usr/share/zoneinfo/Etc/UTC
+ dest: /etc/localtime
+ mode: '0644'
+ owner: root
+ group: root
+ notify: restart systemd-timesyncd