Playbook #1

/root/kubeinit/ci/builds/bsU8uCNn/0/kubeinit/kubeinit/kubeinit-aux/kubeinit/playbook.yml

Report Status CLI Date Duration Controller User Versions Hosts Plays Tasks Results Files Records
05 May 2024 01:59:58 +0000 00:12:42.96 nyctea root Ansible 2.15.2 ara 1.6.1 (client), 1.6.1 (server) Python 3.11.4 7 10 778 845 48 1

File: /root/.ansible/collections/ansible_collections/kubeinit/kubeinit/roles/kubeinit_dnsmasq/tasks/main.yml

---
# Copyright kubeinit contributors
# All Rights Reserved.
#
# 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.


#
# "kubeinit_dnsmasq" tasks
#

- name: Create dnsmasq folders
  ansible.builtin.file:
    path: "{{ item | safe | trim }}"
    state: directory
    recurse: yes
    mode: '0755'
  loop: "{{ kubeinit_dnsmasq_directories }}"

- name: Create dnsmasq config file
  ansible.builtin.template:
    src: "dnsmasq.conf.j2"
    dest: "{{ kubeinit_dnsmasq_config_file }}"
    mode: '0644'
  vars:
    kubeinit_dnsmasq_interface: 'ceth0'
    kubeinit_cluster_domain: "{{ hostvars[kubeinit_cluster_name].cluster_domain }}"

- name: Install buildah if required
  ansible.builtin.package:
    state: present
    name: "buildah"

- name: Remove any old dnsmasq buildah container
  ansible.builtin.shell: |
    set -o pipefail
    buildah rm {{ kubeinit_cluster_name }}-dnsmasq || true
  args:
    executable: /bin/bash
  register: _result
  changed_when: "_result.rc == 0"

- name: Create a new working container image
  ansible.builtin.command: buildah from --name {{ kubeinit_cluster_name }}-dnsmasq quay.io/poseidon/dnsmasq
  register: _result
  changed_when: "_result.rc == 0"

- name: Update the container
  ansible.builtin.command: buildah run {{ kubeinit_cluster_name }}-dnsmasq -- apk upgrade
  register: _result
  changed_when: "_result.rc == 0"

- name: Copy generated dnsmasq.conf into container
  ansible.builtin.command: buildah copy {{ kubeinit_cluster_name }}-dnsmasq {{ kubeinit_dnsmasq_config_file }} /etc/dnsmasq.conf
  register: _result
  changed_when: "_result.rc == 0"

- name: Set kubeinit-cluster-name label
  ansible.builtin.command: buildah config --label kubeinit-cluster-name={{ kubeinit_cluster_name }} {{ kubeinit_cluster_name }}-dnsmasq
  register: _result
  changed_when: "_result.rc == 0"

- name: Commit the container image
  ansible.builtin.command: buildah commit {{ kubeinit_cluster_name }}-dnsmasq kubeinit/{{ kubeinit_cluster_name }}-dnsmasq:latest
  register: _result
  changed_when: "_result.rc == 0"

- name: Remove the buildah container
  ansible.builtin.command: buildah rm {{ kubeinit_cluster_name }}-dnsmasq
  register: _result
  changed_when: "_result.rc == 0"

- name: Create a podman container to serve the dnsmasq
  containers.podman.podman_container:
    name: "{{ kubeinit_dnsmasq_service_name }}"
    image: kubeinit/{{ kubeinit_cluster_name }}-dnsmasq:latest
    pod: "{{ kubeinit_deployment_pod_name }}"
    state: stopped
    cap_add:
      - "NET_ADMIN"
      - "NET_RAW"
    command: -d -q -C /etc/dnsmasq.conf
    volumes:
      - "{{ kubeinit_services_data_volume }}:/var/kubeinit/:Z"
  register: _result_container_info
  retries: 5
  delay: 10
  until: not _result_container_info.failed

- name: Create systemd service for podman container
  ansible.builtin.include_role:
    name: kubeinit.kubeinit.kubeinit_services
    tasks_from: create_managed_service.yml
    public: true
  vars:
    _param_service_user_dir: "{{ kubeinit_service_user_dir }}"
    _param_service_user: "{{ kubeinit_service_user }}"
    _param_systemd_service_name: "{{ kubeinit_dnsmasq_service_name }}"
    _param_podman_container_name: "{{ _result_container_info.container.Name }}"
    _param_podman_container_pidfile: "{{ _result_container_info.container.ConmonPidFile }}"

- name: Clear temp facts
  ansible.builtin.set_fact:
    _result_container_info: null