Execution
Date 08 Dec 2025 13:40:18 +0000
Duration 00:10:06.79
Controller aio1.openstack.local
User root
Versions
Ansible 2.18.6
ara 1.7.4 / 1.7.4
Python 3.12.11
Summary
15 Hosts
608 Tasks
2412 Results
18 Plays
158 Files
0 Records

File: /home/zuul/src/opendev.org/openstack/openstack-ansible-lxc_hosts/tasks/lxc_post_install.yml

---
# Copyright 2016, Rackspace US, Inc.
#
# 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.

- name: Ensure the lxc dnsmasq user exists
  ansible.builtin.user:
    name: "{{ lxc_net_dnsmasq_user }}"
    comment: "LXC dnsmasq"
    system: "yes"
    shell: "/bin/false"
    home: "/var/lib/lxc"
  tags:
    - lxc-dnsmasq-user

- name: Drop base config file(s)
  ansible.builtin.template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: "{{ item.owner | default('root') }}"
    group: "{{ item.group | default('root') }}"
    mode: "{{ item.mode | default('0644') }}"
  with_items:
    - { src: lxc-openstack.conf.j2, dest: "/etc/lxc/lxc-openstack.conf" }
    - { src: lxc-net.default.j2, dest: "{{ system_config_dir }}/lxc-net", mode: "0644" }
    - { src: lxc.default.j2, dest: "{{ system_config_dir }}/lxc", mode: "0644" }
    - { src: lxc-openstack-common.conf.j2, dest: "/usr/share/lxc/config/common.conf.d/80-openstack-common.conf" }
    - { src: lxc-system-manage.j2, dest: "/usr/local/bin/lxc-system-manage", mode: "0755" }
    - { src: systemd-overrides.conf.j2, dest: "/etc/systemd/system.conf.d/osa-lxc-hosts.conf" }
  notify:
    - Reload systemd units
  tags:
    - lxc-files
    - lxc-config

- name: Drop lxc veth check script
  ansible.builtin.copy:
    src: "lxc-veth-check.sh"
    dest: "/usr/local/bin/lxc-veth-check"
    owner: "root"
    group: "root"
    mode: "0755"
  tags:
    - lxc-files
    - lxc-config

# NOTE: Remove this task after 2025.1
- name: Remove DefaultTasksMax value from default config
  ansible.builtin.lineinfile:
    dest: /etc/systemd/system.conf
    state: absent
    regexp: "^.*DefaultTasksMax.*$"
    line: "DefaultTasksMax={{ lxc_default_tasks_max }}"
  when:
    - ansible_facts['service_mgr'] == 'systemd'
  notify:
    - Reload systemd units
  tags:
    - lxc-config

- name: Set sshd MaxSessions
  ansible.builtin.lineinfile:
    dest: /etc/ssh/sshd_config
    state: present
    regexp: "^#?MaxSessions.*$"
    line: "MaxSessions 50"
  notify:
    - Restart sshd
  tags:
    - lxc-config

- name: Tuning kernel for lxc
  ansible.posix.sysctl:
    name: "{{ item.key }}"
    value: "{{ item.value }}"
    sysctl_set: "{{ item.set | default('yes') }}"
    sysctl_file: "{{ lxc_sysctl_file }}"
    state: "{{ item.state | default('present') }}"
    reload: "{{ item.reload | default('yes') }}"
  failed_when: false
  with_items: "{{ lxc_kernel_options }}"