Skip to content

Instantly share code, notes, and snippets.

@nmasse-itix
Last active January 14, 2021 16:54
Show Gist options
  • Save nmasse-itix/ad886b2f64057fd9929831e9d90b9b4e to your computer and use it in GitHub Desktop.
Save nmasse-itix/ad886b2f64057fd9929831e9d90b9b4e to your computer and use it in GitHub Desktop.
How to use podman with Ansible

How to use podman with Ansible

- 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
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