diff --git a/defaults/main.yml b/defaults/main.yml index d12169e..f8c4324 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,6 +31,8 @@ lxc_container_vg_name: lxc lxc_container_default_mtu: "1500" +lxc_container_domain: "openstack.local" + # LXC image server lxc_image_cache_server: images.linuxcontainers.org diff --git a/releasenotes/notes/RFC-1034-and-1035-container-update-6e880e4b45e11cf0.yaml b/releasenotes/notes/RFC-1034-and-1035-container-update-6e880e4b45e11cf0.yaml new file mode 100644 index 0000000..ee12045 --- /dev/null +++ b/releasenotes/notes/RFC-1034-and-1035-container-update-6e880e4b45e11cf0.yaml @@ -0,0 +1,15 @@ +--- +features: + - LXC containers will now have a proper RFC1034/5 hostname set during post + build tasks. A localhost entry for 127.0.1.1 will be created by converting + all of the "_" in the ``inventory_hostname`` to "-". Containers will be + created with a default domain of *openstack.local*. + This domain name can be customized to meet your deployment needs by + setting the option ``lxc_container_domain``. +upgrade: + - LXC containers will now have a proper RFC1034/5 hostname set during post + build tasks. A localhost entry for 127.0.1.1 will be created by converting + all of the "_" in the ``inventory_hostname`` to "-". Containers will be + created with a default domain of *openstack.local*. + This domain name can be customized to meet your deployment needs by + setting the option ``lxc_container_domain``. diff --git a/tasks/container_create.yml b/tasks/container_create.yml index bb52ab3..6f66920 100644 --- a/tasks/container_create.yml +++ b/tasks/container_create.yml @@ -190,3 +190,44 @@ - global_environment_variables is defined tags: - lxc-container-proxy + +- name: Create localhost config + lineinfile: + dest: "/etc/hosts" + regexp: "^127.0.0.1" + line: "127.0.0.1 localhost" + owner: "root" + group: "root" + mode: "0644" + remote_user: root + tags: + - lxc-container-hostname + +- name: Create domain config + lineinfile: + dest: "/etc/hosts" + regexp: "^127.0.1.1" + line: "127.0.1.1 {{ inventory_hostname | replace('_', '-') }}.{{ lxc_container_domain }} {{ inventory_hostname | replace('_', '-') }}" + owner: "root" + group: "root" + mode: "0644" + remote_user: root + tags: + - lxc-container-hostname + +- name: Create hostname + copy: + dest: "/etc/hostname" + content: "{{ inventory_hostname | replace('_', '-') }}" + owner: "root" + group: "root" + mode: "0644" + remote_user: root + tags: + - lxc-container-hostname + +- name: Setup hostname + command: hostname -F /etc/hostname + remote_user: root + tags: + - lxc-container-hostname