From 24195da6d787fbc4474e6c02bc273e034ac9f2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 26 Feb 2018 16:19:49 +0100 Subject: [PATCH] Disable the management of /etc/hosts by Proxmox --- CHANGELOG.md | 7 ++++++- README.md | 4 ++++ defaults/main.yml | 2 ++ tasks/main.yml | 12 +++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d11664b..6c8c4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ +## v1.0.2 + +### Enhancements +* Disable the management of /etc/hosts by Proxmox. + ## v1.0.1 -## Enhancements +### Enhancements * Add example playbook. * localhost line sould not contain hostname information (see https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution). * Purge /etc/hosts of multiple lines that contains $HOSTNAME without the default ipv4 ip address. diff --git a/README.md b/README.md index a8c967c..8207455 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Manage some basics configuration for IPR's servers. * **basics__hosts_localhost_content** : Content of the localhost (127.0.0.1) line [default : `localhost.localdomain localhost`]. * **basics__hosts_ipv4_manage** : If the ipv4 address line should be managed [default : `false`]. * **basics__hosts_ipv4_content** : Content of the ipv4 address line [default : `{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }}`]. +* **basics__proxmox_disable_hosts** : Disable the management of **/etc/hosts** file by Proxmox for LXC containers [default : `True`]. ## Example Playbook @@ -53,6 +54,9 @@ Ensure to have the correct fqdn and hostname in /etc/hosts : - You can choose to define the permanent ip (ipv4) line content. - All other lines that contains hostname without this permanent ip address will be removed. +For LXC containers, also ensure to disable the management of /etc/hosts by Proxmox : +- Touch a /etc/.pve-ignore.hosts file. + ## Development This source code comes from our [Gogs instance][basics source] and the [Github repo][basics github] exist just to be able to send the role to Ansible Galaxy… diff --git a/defaults/main.yml b/defaults/main.yml index b21eae0..eeb576f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,3 +10,5 @@ basics__hosts_localhost_content: "localhost.localdomain localhost" basics__hosts_ipv4_manage: false basics__hosts_ipv4_content: "{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }}" +# Proxmox +basics__proxmox_disable_hosts: True diff --git a/tasks/main.yml b/tasks/main.yml index f3dd44d..ddce8dd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ --- # tasks file for basics -## Modify /etc/hosts +## Modify /etc/hosts {{{ - name: Config host - Set 127.0.0.1 line in hosts file lineinfile: @@ -33,3 +33,13 @@ ansible_default_ipv4.address is defined) ## }}} + +## Proxmox {{{ + +- name: Disable modification of /etc/hosts by Proxmox + file: + path: /etc/.pve-ignore.hosts + state: '{{ "touch" if basics__proxmox_disable_hosts else "absent" }}' + when: ansible_virtualization_type == "lxc" + +## }}}