BaseOS v1.0.21 #6
@ -8,7 +8,7 @@ namespace: jchristianh
|
|||||||
name: baseos
|
name: baseos
|
||||||
|
|
||||||
# The version of the collection. Must be compatible with semantic versioning
|
# The version of the collection. Must be compatible with semantic versioning
|
||||||
version: 1.0.20
|
version: 1.0.21
|
||||||
|
|
||||||
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
||||||
readme: README.md
|
readme: README.md
|
||||||
|
13
roles/hostname/defaults/main.yml
Normal file
13
roles/hostname/defaults/main.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
hostname_project_author : Chris Hammer
|
||||||
|
hostname_project_email : chris@thezengarden.net
|
||||||
|
hostname_project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||||
|
|
||||||
|
hostname_template_header : The Zen Garden
|
||||||
|
|
||||||
|
hostname_hostname_file : /etc/hostname
|
||||||
|
hostname_hostname_version : 1.0.0
|
||||||
|
hostname_hostname_revision : 240228
|
||||||
|
|
||||||
|
|
||||||
|
...
|
@ -1,9 +1,40 @@
|
|||||||
---
|
---
|
||||||
- name: Set hostname for host
|
|
||||||
|
- name: Use hostname module to set hostname, or failback to command module
|
||||||
|
block:
|
||||||
|
- name: Set hostname for host using hostname module
|
||||||
ansible.builtin.hostname:
|
ansible.builtin.hostname:
|
||||||
name: "{{ inventory_hostname }}"
|
name: "{{ inventory_hostname }}"
|
||||||
notify:
|
notify:
|
||||||
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Ensure hostname package is present
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: hostname
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Set hostname file if running in container
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
hostname_hostname_file: "{{ hostname_hostname_file }}.container"
|
||||||
|
when:
|
||||||
|
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||||
|
|
||||||
|
- name: Add entry into hostname file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "{{ hostname_hostname_file }}"
|
||||||
|
line: "{{ inventory_hostname }}"
|
||||||
|
state: present
|
||||||
|
create: true
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Update hostname from /etc/hostname
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "hostname -F {{ hostname_hostname_file }}"
|
||||||
|
notify:
|
||||||
|
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
||||||
|
when:
|
||||||
|
- not ansible_virtualization_type | regex_search("docker|podman|container")
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Set resolv_conf_file if running in container
|
- name: Set resolv.conf if running in container
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.docker"
|
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.container"
|
||||||
when:
|
when:
|
||||||
- ansible_virtualization_type | regex_search("docker|podman|container")
|
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user