set hostname during update_hosts.yml playbook
This commit is contained in:
@@ -27,43 +27,43 @@
|
|||||||
become: true
|
become: true
|
||||||
- role: rsyslog
|
- role: rsyslog
|
||||||
become: true
|
become: true
|
||||||
- role: datadog.datadog
|
# - role: datadog.datadog
|
||||||
become: true
|
# become: true
|
||||||
when: ansible_architecture != 'armv7l'
|
# when: ansible_architecture != 'armv7l'
|
||||||
datadog_checks:
|
# datadog_checks:
|
||||||
reboot_required:
|
# reboot_required:
|
||||||
init_config:
|
# init_config:
|
||||||
instances:
|
# instances:
|
||||||
-
|
# -
|
||||||
oom_kill:
|
# oom_kill:
|
||||||
init_config:
|
# init_config:
|
||||||
instances:
|
# instances:
|
||||||
-
|
# -
|
||||||
systemd:
|
# systemd:
|
||||||
- unit_names:
|
# - unit_names:
|
||||||
- cron.service
|
# - cron.service
|
||||||
- k3s.service
|
# - k3s.service
|
||||||
- named.service
|
# - named.service
|
||||||
- ssh.servce
|
# - ssh.servce
|
||||||
- apt-daily-upgrade.timer
|
# - apt-daily-upgrade.timer
|
||||||
|
#
|
||||||
|
# bind9:
|
||||||
|
# init_config:
|
||||||
|
# instances:
|
||||||
|
# - url: "http://ns01:8053/"
|
||||||
|
# - url: "http://ns02:8053/"
|
||||||
|
#
|
||||||
|
# datadog_integration:
|
||||||
|
# datadog-reboot_required:
|
||||||
|
# action: install
|
||||||
|
# version: 1.0.0
|
||||||
|
# third_party: true
|
||||||
|
# datadog-bind9:
|
||||||
|
# action: install
|
||||||
|
# version: 1.0.0
|
||||||
|
# third_party: true
|
||||||
|
|
||||||
bind9:
|
# - role: datadog.datadog
|
||||||
init_config:
|
# become: true
|
||||||
instances:
|
# datadog_agent_flavor: datadog-iot-agent
|
||||||
- url: "http://ns01:8053/"
|
# when: ansible_architecture == 'armv7l'
|
||||||
- url: "http://ns02:8053/"
|
|
||||||
|
|
||||||
datadog_integration:
|
|
||||||
datadog-reboot_required:
|
|
||||||
action: install
|
|
||||||
version: 1.0.0
|
|
||||||
third_party: true
|
|
||||||
datadog-bind9:
|
|
||||||
action: install
|
|
||||||
version: 1.0.0
|
|
||||||
third_party: true
|
|
||||||
|
|
||||||
- role: datadog.datadog
|
|
||||||
become: true
|
|
||||||
datadog_agent_flavor: datadog-iot-agent
|
|
||||||
when: ansible_architecture == 'armv7l'
|
|
||||||
|
|||||||
@@ -16,8 +16,15 @@ machines:
|
|||||||
|
|
||||||
remove: []
|
remove: []
|
||||||
|
|
||||||
|
cubox-m:
|
||||||
|
fstab:
|
||||||
|
add: []
|
||||||
|
|
||||||
|
remove: []
|
||||||
|
|
||||||
home:
|
home:
|
||||||
fstab:
|
fstab:
|
||||||
add: []
|
add: []
|
||||||
|
|
||||||
remove: []
|
remove: []
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
autoremove: yes
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
- name: check for reboot required
|
- 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
|
- name: Install required packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
update_cache: yes
|
|
||||||
cache_valid_time: 3600
|
|
||||||
state: latest
|
state: latest
|
||||||
with_items:
|
with_items:
|
||||||
- htop
|
- htop
|
||||||
- attr
|
- attr
|
||||||
- python3-psutil
|
- python3-psutil
|
||||||
- acl
|
- acl
|
||||||
|
- bind9-dnsutils
|
||||||
|
- iputils-ping
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
|
- include_tasks: set_hostname.yml
|
||||||
|
|
||||||
- include_tasks: install_tools.yml
|
- include_tasks: install_tools.yml
|
||||||
|
|
||||||
# update packages to latest
|
# update packages to latest
|
||||||
- include_tasks: apply_updates.yml
|
- include_tasks: apply_updates.yml
|
||||||
|
|
||||||
- name: update login screen
|
#- name: update login screen
|
||||||
include_tasks: motd.yml
|
# include_tasks: motd.yml
|
||||||
|
|
||||||
- name: update fstab
|
- name: update fstab
|
||||||
include_tasks: update_fstab.yml
|
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'
|
||||||
9
ansible-5/roles/common/templates/hosts.j2
Normal file
9
ansible-5/roles/common/templates/hosts.j2
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
127.0.0.1 localhost
|
||||||
|
127.0.1.1 {{inventory_hostname}}
|
||||||
|
|
||||||
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
#fe00::0 ip6-localnet #missing on debian?
|
||||||
|
#ff00::0 ip6-mcastprefix #missing on debian?
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
Reference in New Issue
Block a user