update_hosts.yml with motd, login page and rsyslog config
This commit is contained in:
18
ansible-5/roles/common/tasks/apply_updates.yml
Normal file
18
ansible-5/roles/common/tasks/apply_updates.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# update packages to latest
|
||||
|
||||
- name: run apt updates
|
||||
apt:
|
||||
upgrade: dist
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: check for reboot required
|
||||
stat:
|
||||
path: /var/run/reboot-required
|
||||
register: reboot_required
|
||||
|
||||
- name: reboot after updates
|
||||
reboot:
|
||||
when: reboot_required.stat.exists
|
||||
6
ansible-5/roles/common/tasks/main.yml
Normal file
6
ansible-5/roles/common/tasks/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
# update packages to latest
|
||||
|
||||
- include_tasks: apply_updates.yml
|
||||
|
||||
- include_tasks: motd.yml
|
||||
38
ansible-5/roles/common/tasks/motd.yml
Normal file
38
ansible-5/roles/common/tasks/motd.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
# main tasks for setting up motd dynamic shell header
|
||||
|
||||
- debug: var=ansible_nodename
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: latest
|
||||
with_items:
|
||||
- lsb-release
|
||||
- figlet
|
||||
- update-motd
|
||||
- lm-sensors
|
||||
when: ansible_architecture != 'armv7l'
|
||||
|
||||
|
||||
- name: remove help text
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ item }}"
|
||||
with_items:
|
||||
- /etc/update-motd.d/10-help-text
|
||||
- /etc/update-motd.d/51-cloudguest
|
||||
when: ansible_architecture != 'armv7l'
|
||||
|
||||
|
||||
- name: add new info
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: /etc/update-motd.d/{{ item.dest }}
|
||||
mode: 755
|
||||
with_items:
|
||||
- { src: motd/hostname.sh, dest: 10-hostname }
|
||||
- { src: motd/systats.sh, dest: 11-sysstats}
|
||||
when: ansible_architecture != 'armv7l'
|
||||
Reference in New Issue
Block a user