diff --git a/tasks/lxc_container_config.yml b/tasks/lxc_container_config.yml index faacdb3..f3ee1b8 100644 --- a/tasks/lxc_container_config.yml +++ b/tasks/lxc_container_config.yml @@ -38,7 +38,7 @@ file: path: "{{ item['host_directory'] }}" state: "directory" - with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}" + with_items: "{{ lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) }}" delegate_to: "{{ physical_host }}" - name: Add bind mount configuration to container @@ -46,7 +46,7 @@ dest: "/var/lib/lxc/{{ inventory_hostname }}/config" line: "lxc.mount.entry = {{ item['host_directory'] }} {{ item['container_directory'].lstrip('/') }} none bind,create=dir 0 0" backup: "true" - with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}" + with_items: "{{ lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) }}" delegate_to: "{{ physical_host }}" register: bind_configuration_container notify: diff --git a/templates/container-setup.sh.j2 b/templates/container-setup.sh.j2 index 1fb36cf..8f5f196 100644 --- a/templates/container-setup.sh.j2 +++ b/templates/container-setup.sh.j2 @@ -4,7 +4,7 @@ set -ev # Generate the lxc container create prep commands {{ lxc_container_commands }} -{% for item in lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) %} +{% for item in lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) %} {% if item['container_directory'] is defined %} # Create dir "{{ item['container_directory'] }}" mkdir -p "{{ item['container_directory'] }}" diff --git a/templates/sysctl-container.init.j2 b/templates/sysctl-container.init.j2 index 621a9cd..78d12d4 100644 --- a/templates/sysctl-container.init.j2 +++ b/templates/sysctl-container.init.j2 @@ -10,7 +10,7 @@ Before=sysinit.target shutdown.target [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/sbin/sysctl -p +ExecStart={{ sysctl_path }}/sysctl -p TimeoutSec=90s [Install] diff --git a/vars/gentoo.yml b/vars/gentoo.yml new file mode 100644 index 0000000..a91fbfa --- /dev/null +++ b/vars/gentoo.yml @@ -0,0 +1,46 @@ +--- +# Copyright 2018, Matthew Thode +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TODO: COnfigure with networkd or the other system. +# These seem to be unused placeholder items +lxc_container_default_route_interfaces: "/etc/network/interfaces.d/{{ item.value.interface }}.cfg" +lxc_container_interface_target: "/etc/network/interfaces.d/{{ item.value.interface }}.cfg" +lxc_container_default_interface: "/etc/network/interfaces" + +# no official systemd image is published, but machinectl seems to work +lxc_container_backing_store: machinectl + +lxc_container_map: + distro: gentoo + arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_architecture'] | lower ) }}" + release: 17.0-systemd + +lxc_container_default_config_list: + - "lxc.start.auto=1" + - "lxc.start.delay=15" + - "lxc.group=onboot" + - "lxc.group=openstack" + - "lxc.autodev=1" + - "lxc.pty.max=1024" + - "lxc.hook.autodev=/var/lib/lxc/{{ inventory_hostname }}/autodev" + +sysctl_path: "/usr/sbin" + +# shared binpkgs and distfiles +_lxc_container_bind_mounts: + - host_directory: "/openstack/portage/packages" + container_directory: "/usr/portage/packages" + - host_directory: "/openstack/portage/distfiles" + container_directory: "/usr/portage/distfiles" diff --git a/vars/main.yml b/vars/main.yml index 17a4af0..f4d81b0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -18,3 +18,5 @@ # and "lxc_container_networks" variables and combined into a single # immutable hash. lxc_container_networks_combined: "{{ container_networks | default({}) | combine(container_extra_networks | default({})) | combine(lxc_container_networks) }}" +sysctl_path: "/sbin" +_lxc_container_bind_mounts: []