Skip to content

Commit

Permalink
Manages Hostname "use"
Browse files Browse the repository at this point in the history
  • Loading branch information
HanXHX committed May 19, 2020
1 parent b721e2d commit c6ac7ca
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 35 deletions.
16 changes: 0 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Supported versions
Requirements
------------

Min Ansible 2.5
Min Ansible 2.9

Role Variables
--------------
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 1 addition & 13 deletions tasks/hostname.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}"
Expand Down

0 comments on commit c6ac7ca

Please sign in to comment.