Last active
January 14, 2021 16:54
-
-
Save nmasse-itix/ad886b2f64057fd9929831e9d90b9b4e to your computer and use it in GitHub Desktop.
How to use podman with Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- dnf: | |
name: | |
- podman | |
- podman-plugins | |
- buildah | |
state: installed | |
- name: Inspect the default network created by podman | |
command: podman network inspect podman | |
register: podman_network_inspect | |
changed_when: false | |
- name: Check if the default network needs to be patched to add the "dnsname" plugin | |
set_fact: | |
podman_default_network_needs_patch: '{{ "dnsname" not in network_plugins }}' | |
vars: | |
network_plugins: '{{ podman_network_inspect.stdout | from_json | json_query("[0].plugins[].type") | list }}' | |
- name: Remove the default podman network | |
containers.podman.podman_network: | |
name: podman | |
state: absent | |
when: podman_default_network_needs_patch | |
- name: Re-create the default podman network (with the "dnsname" plugin) | |
containers.podman.podman_network: | |
name: podman | |
state: present | |
subnet: 10.88.0.0/16 | |
when: podman_default_network_needs_patch | |
- name: Install XXX | |
containers.podman.podman_container: | |
name: truc | |
image: 'docker.io/test/truc:latest' | |
state: started | |
command: | |
- /usr/bin/truc | |
volume: | |
- '/opt/truc/etc:/etc/truc:z' | |
- name: Wait for Keycloak to get ready | |
uri: | |
url: https://{{ keycloak_hostname }}/auth/realms/itix/.well-known/openid-configuration | |
timeout: 10 | |
retries: 20 | |
delay: 5 | |
register: healthcheck | |
until: not healthcheck.failed | |
tags: | |
- healthcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collections: | |
- name: containers.podman | |
version: '>=1.4.1' # 1.4.1 is the minimum when working with podman 2.2 | |
- name: ansible.posix | |
- name: community.general |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment