From c6ac7ca417958e201bf4560530f5be632de207e1 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Tue, 19 May 2020 12:34:06 +0200 Subject: [PATCH] Manages Hostname "use" --- .travis.yml | 16 ---------------- README.md | 3 ++- defaults/main.yml | 1 + meta/main.yml | 2 +- tasks/hostname.yml | 14 +------------- tasks/main.yml | 8 ++++---- 6 files changed, 9 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index efc4a00..33ddd91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,4 @@ env: - - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.5,<2.6' - - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5,<2.6' - - PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.5,<2.6' - - PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.5,<2.6' - - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.6,<2.7' - - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.6,<2.7' - - PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.6,<2.7' - - PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.6,<2.7' - - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.7,<2.8' - - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.7,<2.8' - - PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.7,<2.8' - - PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.7,<2.8' - - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.8,<2.9' - - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.8,<2.9' - - PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.8,<2.9' - - PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.8,<2.9' - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.9,<2.10' - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.9,<2.10' - PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.9,<2.10' diff --git a/README.md b/README.md index ce16178..eeb6cdd 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Supported versions Requirements ------------ -Min Ansible 2.5 +Min Ansible 2.9 Role Variables -------------- @@ -58,6 +58,7 @@ Theses variables define hostname to configure APT (normal repo and backports): ### System configuration - `dbs_hostname`: system hostname +- `dbs_hostname_use_strategy`: strategy used to set hostname check "use" in [hostname module](https://docs.ansible.com/ansible/latest/modules/hostname_module.html). You should update this var only if hostname fails (in LXC for example). - `dbs_default_locale`: default system locale - `dbs_locales`: list of installed locales - `dbs_timezone`: system timezone. If you need a "standard" timezone like UTC, you must use prefix "Etc/" (ex: "Etc/UTC") diff --git a/defaults/main.yml b/defaults/main.yml index 2125ff7..db7772c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,7 @@ dbs_repo_old: "{% if ansible_local | d() and ansible_local.apt_sources | d() and # System configuration # ------------------------- dbs_hostname: 'debian-boostrap.local' +dbs_hostname_use_strategy: null dbs_locales: - 'en_US.UTF-8' dbs_default_locale: 'en_US.UTF-8' diff --git a/meta/main.yml b/meta/main.yml index b43b523..300e4cd 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -4,7 +4,7 @@ galaxy_info: description: Normalize and prepare a Debian/Devuan/Kali Linux server company: license: GPLv2 - min_ansible_version: 2.5 + min_ansible_version: 2.9 platforms: - name: Debian versions: diff --git a/tasks/hostname.yml b/tasks/hostname.yml index cdd71e9..754b214 100644 --- a/tasks/hostname.yml +++ b/tasks/hostname.yml @@ -1,11 +1,9 @@ --- -# Doc: https://wiki.debian.org/HowTo/ChangeHostname -# TODO : notify other services - - name: HOSTNAME hostname: name: "{{ dbs_hostname }}" + use: "{% if dbs_hostname_use_strategy is not none %}{{ dbs_hostname_use_strategy }}{% elif ansible_service_mgr == 'systemd' %}systemd{% else %}debian{% endif %}" notify: restart rsyslog register: change_hostname @@ -15,13 +13,3 @@ dest: /etc/hosts notify: restart rsyslog when: dbs_clean_hosts - -# Don't work on Jessie -#- name: SERVICE | Force hostname.sh start -# service: name=hostname.sh state=started -# when: change_hostname.changed - -# Dangerous... -#- name: SERVICE | Force networking restart -# service: name=networking state=restarted -# when: change_hostname.changed diff --git a/tasks/main.yml b/tasks/main.yml index 62a8104..46f33af 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,10 +12,6 @@ - name: INCLUDE | Prepare system include: prepare.yml -- name: INCLUDE | Set hostname - include: hostname.yml - when: dbs_set_hostname and not dbs_is_docker - - name: INCLUDE | Configure APT include: apt.yml @@ -29,6 +25,10 @@ not dbs_use_systemd and not dbs_is_docker +- name: INCLUDE | Set hostname + include: hostname.yml + when: dbs_set_hostname and not dbs_is_docker + - name: TIMEZONE | Set timezone: name: "{{ dbs_timezone }}"