diff options
| author | spmfox <spmfox@foxwd.com> | 2024-08-27 17:34:55 -0400 |
|---|---|---|
| committer | spmfox <spmfox@foxwd.com> | 2024-08-27 17:34:55 -0400 |
| commit | 5ca4fbf2cfe781efedc7c078acaa826c6ad39b10 (patch) | |
| tree | 598ff2c8b51948091ffa1eb1fbb6ef6f7b26b776 /containers.yml | |
| parent | 4aa6b11581718f66e711bf26fbb41e96fa3a4661 (diff) | |
converting to roles, converting from runlabels to quadlet ~ breaking change
Diffstat (limited to 'containers.yml')
| -rw-r--r-- | containers.yml | 148 |
1 files changed, 2 insertions, 146 deletions
diff --git a/containers.yml b/containers.yml index ab61772..59de80c 100644 --- a/containers.yml +++ b/containers.yml @@ -1,149 +1,5 @@ - hosts: localhost tasks: - - name: Rebuild images - containers.podman.podman_image: - name: "{{ item.name }}:{{ ansible_date_time.date }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}" - path: "{{ item.path }}" - build: - file: "{{ item.file }}" - cache: false - tags: rebuild - loop: "{{ containers }}" - - - name: Tag new images to latest - containers.podman.podman_tag: - image: "{{ item.name }}:{{ ansible_date_time.date }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}" - target_names: "{{ item.name }}:latest" - tags: rebuild - loop: "{{ containers }}" - - - name: Stop systemd pod service - ansible.builtin.systemd: - name: "pod-{{ pod.name }}.service" - state: stopped - scope: user - ignore_errors: true - tags: - - remove - - service-stop - when: pod is defined - - - name: Remove systemd pod service file - ansible.builtin.file: - path: "~/.config/systemd/user/pod-{{ pod.name }}.service" - state: absent - tags: remove - when: pod is defined - - - name: Stop systemd container service - ansible.builtin.systemd: - name: "container-{{ item.name }}.service" - state: stopped - scope: user - ignore_errors: true - tags: - - remove - - service-stop - loop: "{{ containers }}" - - - name: Remove systemd container service file - ansible.builtin.file: - path: "~/.config/systemd/user/container-{{ item.name }}.service" - state: absent - tags: remove - loop: "{{ containers }}" - - - name: Remove pod - containers.podman.podman_pod: - name: "{{ pod.name }}" - state: absent - tags: - - remove - - container-stop - when: pod is defined - - - name: Remove containers - containers.podman.podman_container: - name: "{{ item.name }}" - state: absent - tags: - - remove - - container-stop - loop: "{{ containers }}" - - - name: Create pod - containers.podman.podman_pod: - name: "{{ pod.name }}" - ports: "{{ pod.ports }}" - network: "{{ pod.network | default(omit) }}" - state: started - tags: container-start - when: pod is defined - - - name: Start containers - ansible.builtin.shell: "podman container runlabel {{ item.runlabel }} {{ item.name}}:latest" - tags: container-start - loop: "{{ containers }}" - - - name: Generate systemd service file for pod - containers.podman.podman_generate_systemd: - name: "{{ pod.name }}" - dest: "~/.config/systemd/user/" - new: true - tags: generate-systemd - when: pod is defined - - - name: Generate systemd service file for container (when pod is not in use) - containers.podman.podman_generate_systemd: - name: "{{ item.name }}" - dest: "~/.config/systemd/user/" - new: true - tags: generate-systemd - loop: "{{ containers }}" - when: pod is not defined - - - name: Reload systemd daemon - ansible.builtin.systemd: - daemon_reload: true - scope: user - tags: - - remove - - generate-systemd - - - name: Pause for container full startup - ansible.builtin.pause: - seconds: 30 - - - name: Remove pod - containers.podman.podman_pod: - name: "{{ pod.name }}" - state: absent - when: pod is defined - - - name: Remove containers - containers.podman.podman_container: - name: "{{ item.name }}" - state: absent - loop: "{{ containers }}" - - - name: Start systemd pod service - ansible.builtin.systemd: - name: "pod-{{ pod.name}}.service" - state: started - enabled: true - scope: user - tags: service-start - when: pod is defined - - - name: Start systemd container service - ansible.builtin.systemd: - name: "container-{{ item.name }}.service" - state: started - enabled: true - scope: user - tags: service-start - loop: "{{ containers }}" - - - name: Prune old images - ansible.builtin.shell: "podman image prune -f" + - ansible.builtin.import_role: + name: "containers" |
