Playbook #1

/root/kubeinit/ci/builds/6mbKNrxD/0/kubeinit/kubeinit/kubeinit-aux/kubeinit/playbook.yml

Report Status CLI Date Duration Controller User Versions Hosts Plays Tasks Results Files Records
27 Oct 2023 17:25:14 +0000 00:14:23.04 nyctea root Ansible 2.15.2 ara 1.6.1 (client), 1.6.1 (server) Python 3.11.4 5 9 708 708 43 1

File: /root/.ansible/collections/ansible_collections/kubeinit/kubeinit/roles/kubeinit_haproxy/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.


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

- name: Create HAProxy config file
  ansible.builtin.template:
    src: "haproxy.cfg.j2"
    dest: "{{ kubeinit_haproxy_config_file }}"
    mode: '0644'

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

- name: Remove any old haproxy buildah container
  ansible.builtin.shell: |
    set -o pipefail
    buildah rm {{ kubeinit_cluster_name }}-haproxy || 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 }}-haproxy quay.io/kubeinit/haproxy:2.3
  register: _result
  changed_when: "_result.rc == 0"

- name: Update the container
  ansible.builtin.command: buildah run {{ kubeinit_cluster_name }}-haproxy -- apt-get -y update
  register: _result
  changed_when: "_result.rc == 0"

- name: Copy generated haproxy.cfg into container
  ansible.builtin.command: buildah copy {{ kubeinit_cluster_name }}-haproxy {{ kubeinit_haproxy_config_file }} /usr/local/etc/haproxy/haproxy.cfg
  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 }}-haproxy
  register: _result
  changed_when: "_result.rc == 0"

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

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

- name: Create a podman container to serve the haproxy
  containers.podman.podman_container:
    name: "{{ kubeinit_haproxy_service_name }}"
    image: kubeinit/{{ kubeinit_cluster_name }}-haproxy:latest
    pod: "{{ kubeinit_deployment_pod_name }}"
    state: stopped
    volumes:
      - "{{ kubeinit_haproxy_directory_lib }}:/var/lib/haproxy:Z"
      - "{{ 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_haproxy_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