Refactor Ansible tasks and templates for improved consistency and clarity

This commit is contained in:
2026-07-31 02:24:42 +02:00
parent 81ef678904
commit 46327da2ac
52 changed files with 1679 additions and 1461 deletions
+21 -15
View File
@@ -1,14 +1,14 @@
---
- name: (root_files_scripts.yml) Ensure directory /root/bin exists
file:
ansible.builtin.file:
path: /root/bin
owner: root
group: root
mode: '0700'
state: directory
when:
- groups['file_server']|string is search(inventory_hostname)
- groups['file_server'] | string is search(inventory_hostname)
- name: (root_files_scripts.yml) Ensure script 'wakeup_lan.sh' is present
ansible.builtin.template:
@@ -16,36 +16,42 @@
dest: /root/bin/wakeup_lan.sh
owner: root
group: root
mode: 0755
mode: "0755"
when:
- groups['file_server']|string is search(inventory_hostname)
- groups['file_server'] | string is search(inventory_hostname)
tags:
- wakeup_lan
- name: (root_files_scripts.yml) Check file '/etc/motd.ORIG' exists
stat:
ansible.builtin.stat:
path: /etc/motd.ORIG
register: etc_motd_ORIG
register: common_etc_motd_orig
when:
- "groups['file_server']|string is search(inventory_hostname)"
- groups['file_server'] | string is search(inventory_hostname)
tags:
- etc_motd
- name: (basic.yml) Backup installation version of file '/etc/motd'
command: cp -a /etc/motd /etc/motd.ORIG
ansible.builtin.copy:
src: /etc/motd
dest: /etc/motd.ORIG
remote_src: true
owner: root
group: root
mode: "0644"
force: false
when:
- "groups['file_server']|string is search(inventory_hostname)"
- etc_motd_ORIG.stat.exists == False
- groups['file_server'] | string is search(inventory_hostname)
- not common_etc_motd_orig.stat.exists
tags:
- etc_motd
- name: (root_files_scripts.yml) Write new '/etc/motd' file..
shell: >
ansible.builtin.shell: >
figlet '{{ nis_server_name.split(".")[0] }}' > /etc/motd
changed_when: true
when:
- "groups['file_server']|string is search(inventory_hostname)"
- etc_motd_ORIG.stat.exists == False
- groups['file_server'] | string is search(inventory_hostname)
- not common_etc_motd_orig.stat.exists
tags:
- etc_motd