Merge "Use hostnamectl to set the container hostname"

This commit is contained in:
Zuul 2018-03-19 13:13:40 +00:00 committed by Gerrit Code Review
commit 8c8a22affa
2 changed files with 13 additions and 21 deletions

View File

@ -73,13 +73,6 @@
when:
- lxc_container_enable_resolved | bool
- name: Enable hostnamed
systemd:
name: systemd-hostnamed
state: started
enabled: true
daemon_reload: true
- name: Enable dbus
systemd:
name: dbus
@ -91,6 +84,19 @@
systemd:
daemon_reload: true
- name: Start hostnamed
systemd:
name: systemd-hostnamed
state: started
enabled: true
daemon_reload: true
listen: Enable hostnamed
- name: Set hostnamectl name
command: "/usr/bin/hostnamectl --static --pretty --transient set-hostname {{ inventory_hostname | replace('_', '-') | quote }}"
changed_when: false
listen: Enable hostnamed
# NOTE(hwoarang) openSUSE randomly fails to start the service
# with an error like the following one
# sysctl-container.service: Failed at step CGROUP spawning /sbin/sysctl: No such device

View File

@ -245,20 +245,6 @@
mode: "0644"
remote_user: root
- name: Create hostname
copy:
dest: "/etc/hostname"
content: "{{ inventory_hostname | replace('_', '-') }}"
owner: "root"
group: "root"
mode: "0644"
remote_user: root
- name: Setup hostname
command: hostname -F /etc/hostname
changed_when: false
remote_user: root
- name: Ensure the hostnamed override directory exists
file:
path: "/etc/systemd/system/systemd-hostnamed.service.d"