Skip to content

Commit c6ac7ca

Browse files
committed
Manages Hostname "use"
1 parent b721e2d commit c6ac7ca

File tree

6 files changed

+9
-35
lines changed

6 files changed

+9
-35
lines changed

.travis.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
env:
2-
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.5,<2.6'
3-
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5,<2.6'
4-
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.5,<2.6'
5-
- PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.5,<2.6'
6-
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.6,<2.7'
7-
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.6,<2.7'
8-
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.6,<2.7'
9-
- PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.6,<2.7'
10-
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.7,<2.8'
11-
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.7,<2.8'
12-
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.7,<2.8'
13-
- PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.7,<2.8'
14-
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.8,<2.9'
15-
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.8,<2.9'
16-
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.8,<2.9'
17-
- PLATFORM='docker-ubuntu-bionic' ANSIBLE_VERSION='ansible>=2.8,<2.9'
182
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.9,<2.10'
193
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.9,<2.10'
204
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.9,<2.10'

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Supported versions
3333
Requirements
3434
------------
3535

36-
Min Ansible 2.5
36+
Min Ansible 2.9
3737

3838
Role Variables
3939
--------------
@@ -58,6 +58,7 @@ Theses variables define hostname to configure APT (normal repo and backports):
5858
### System configuration
5959

6060
- `dbs_hostname`: system hostname
61+
- `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).
6162
- `dbs_default_locale`: default system locale
6263
- `dbs_locales`: list of installed locales
6364
- `dbs_timezone`: system timezone. If you need a "standard" timezone like UTC, you must use prefix "Etc/" (ex: "Etc/UTC")

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dbs_repo_old: "{% if ansible_local | d() and ansible_local.apt_sources | d() and
1010
# System configuration
1111
# -------------------------
1212
dbs_hostname: 'debian-boostrap.local'
13+
dbs_hostname_use_strategy: null
1314
dbs_locales:
1415
- 'en_US.UTF-8'
1516
dbs_default_locale: 'en_US.UTF-8'

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ galaxy_info:
44
description: Normalize and prepare a Debian/Devuan/Kali Linux server
55
company:
66
license: GPLv2
7-
min_ansible_version: 2.5
7+
min_ansible_version: 2.9
88
platforms:
99
- name: Debian
1010
versions:

tasks/hostname.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22

3-
# Doc: https://wiki.debian.org/HowTo/ChangeHostname
4-
# TODO : notify other services
5-
63
- name: HOSTNAME
74
hostname:
85
name: "{{ dbs_hostname }}"
6+
use: "{% if dbs_hostname_use_strategy is not none %}{{ dbs_hostname_use_strategy }}{% elif ansible_service_mgr == 'systemd' %}systemd{% else %}debian{% endif %}"
97
notify: restart rsyslog
108
register: change_hostname
119

@@ -15,13 +13,3 @@
1513
dest: /etc/hosts
1614
notify: restart rsyslog
1715
when: dbs_clean_hosts
18-
19-
# Don't work on Jessie
20-
#- name: SERVICE | Force hostname.sh start
21-
# service: name=hostname.sh state=started
22-
# when: change_hostname.changed
23-
24-
# Dangerous...
25-
#- name: SERVICE | Force networking restart
26-
# service: name=networking state=restarted
27-
# when: change_hostname.changed

tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
- name: INCLUDE | Prepare system
1313
include: prepare.yml
1414

15-
- name: INCLUDE | Set hostname
16-
include: hostname.yml
17-
when: dbs_set_hostname and not dbs_is_docker
18-
1915
- name: INCLUDE | Configure APT
2016
include: apt.yml
2117

@@ -29,6 +25,10 @@
2925
not dbs_use_systemd and
3026
not dbs_is_docker
3127
28+
- name: INCLUDE | Set hostname
29+
include: hostname.yml
30+
when: dbs_set_hostname and not dbs_is_docker
31+
3232
- name: TIMEZONE | Set
3333
timezone:
3434
name: "{{ dbs_timezone }}"

0 commit comments

Comments
 (0)