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
29 Oct 2023 16:01:56 +0000 00:38:07.95 nyctea root Ansible 2.15.2 ara 1.6.1 (client), 1.6.1 (server) Python 3.11.4 5 6 825 825 48 1

File: /root/.ansible/collections/ansible_collections/kubeinit/kubeinit/roles/kubeinit_services/tasks/create_managed_service.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: Ensure user specific systemd instance are persistent
  ansible.builtin.command: |
    /usr/bin/loginctl enable-linger {{ _param_service_user }}
  register: _result
  changed_when: "_result.rc == 0"
  become: true
  become_user: root

- name: Create systemd user directory
  ansible.builtin.file:
    path: "{{ _param_service_user_dir }}/.config/systemd/user"
    state: directory
    owner: "{{ _param_service_user }}"
    group: "{{ _param_service_user }}"
    mode: '0775'

- name: Copy the podman systemd service file
  ansible.builtin.copy:
    content: |
      [Unit]
      Description=Podman {{ _param_systemd_service_name }}.service
      [Service]
      Restart=on-failure
      ExecStart=/usr/bin/podman start {{ _param_podman_container_name }}
      ExecStop=/usr/bin/podman stop -t 10 {{ _param_podman_container_name }}
      SuccessExitStatus=143
      KillMode=none
      Type=forking
      PIDFile={{ _param_podman_container_pidfile }}
      [Install]
      WantedBy=default.target
    dest: "{{ _param_service_user_dir }}/.config/systemd/user/{{ _param_systemd_service_name }}.service"
    owner: "{{ _param_service_user }}"
    group: "{{ _param_service_user }}"
    mode: '0644'

- name: Reload systemd service
  ansible.builtin.systemd:
    daemon_reexec: yes
    scope: user
  environment:
    DBUS_SESSION_BUS_ADDRESS: "{{ ansible_env.DBUS_SESSION_BUS_ADDRESS|default('unix:path=/run/user/' +  ansible_effective_user_id|string + '/bus') }}"

- name: "Enable the service {{ _param_systemd_service_name }}"
  ansible.builtin.systemd:
    name: "{{ _param_systemd_service_name }}"
    enabled: yes
    scope: user
  environment:
    DBUS_SESSION_BUS_ADDRESS: "{{ ansible_env.DBUS_SESSION_BUS_ADDRESS|default('unix:path=/run/user/' +  ansible_effective_user_id|string + '/bus') }}"

- name: "Start the service: {{ _param_systemd_service_name }}"
  ansible.builtin.systemd:
    name: "{{ _param_systemd_service_name }}"
    state: started
    scope: user
  environment:
    DBUS_SESSION_BUS_ADDRESS: "{{ ansible_env.DBUS_SESSION_BUS_ADDRESS|default('unix:path=/run/user/' +  ansible_effective_user_id|string + '/bus') }}"