set hostname during update_hosts.yml playbook
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
upgrade: dist
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
autoremove: yes
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: check for reboot required
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
---
|
||||
- name: update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: latest
|
||||
with_items:
|
||||
- htop
|
||||
- attr
|
||||
- python3-psutil
|
||||
- acl
|
||||
- bind9-dnsutils
|
||||
- iputils-ping
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
---
|
||||
|
||||
|
||||
- include_tasks: set_hostname.yml
|
||||
|
||||
- include_tasks: install_tools.yml
|
||||
|
||||
# update packages to latest
|
||||
- include_tasks: apply_updates.yml
|
||||
|
||||
- name: update login screen
|
||||
include_tasks: motd.yml
|
||||
#- name: update login screen
|
||||
# include_tasks: motd.yml
|
||||
|
||||
- name: update fstab
|
||||
include_tasks: update_fstab.yml
|
||||
|
||||
|
||||
14
ansible-5/roles/common/tasks/set_hostname.yml
Normal file
14
ansible-5/roles/common/tasks/set_hostname.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
#Try and setup correct hostnames
|
||||
|
||||
- name: Set hostname to {{inventory_hostname}}
|
||||
ansible.builtin.hostname:
|
||||
name: "{{inventory_hostname}}"
|
||||
|
||||
- name: Template a file to /etc/file.conf
|
||||
ansible.builtin.template:
|
||||
src: hosts.j2
|
||||
dest: /etc/hosts
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
Reference in New Issue
Block a user