Skip to content

Instantly share code, notes, and snippets.

@gridhead
Last active June 5, 2021 06:10
Show Gist options
  • Save gridhead/b568ef0d61cb7f44f4bee3229a413af9 to your computer and use it in GitHub Desktop.
Save gridhead/b568ef0d61cb7f44f4bee3229a413af9 to your computer and use it in GitHub Desktop.
Pull Docker Images on an Fedora Podman Host Constructed From a Jinja2 Template
[web]
server1 ansible_host=192.168.0.163
server1 ansible_ssh_user=fedora
server1 ansible_ssh_pass=<your-ssh-password>
server1 ansible_sudo_pass=<your-sudo-password>

Pull Docker Images on an Fedora Podman Host Constructed From a Jinja2 Template

  1. Download the inventory.ini, pull-podman-image-template.yml and pulltemp.j2 to the same directory.
  2. Make changes to the inventory.ini file to change the hostname and username.
  3. Make changes to the pull-podman-image-template.yml file to change the following variables.
    1. hostaddr (to reflect the remote machine name from the inventory.ini file)
    2. username (to reflect the username for the remote machine from the inventory.ini file)
    3. imejdict (to reflect the dictionary of images with tags that need to be downloaded)
  4. Once the changes are completed, execute the following command to populate a playbook with the images listed.
    ansible-playbook pull-podman-image-template.yml -vvv
    
  5. Fetch the containers.podman collection from Ansible Galaxy by executing the following command.
    ansible-galaxy collection install containers.podman
    
  6. Now run the generated playbook on the remote machine by executing the following command.
    ansible-playbook -i inventory.ini pulling_images_for_fedora_rpi4_homeserver.yml -vvv
    

The generated playbook is attached here for convenience.

- name: "Establish template for pulling said list of Podman images from Dockerhub"
hosts: "127.0.0.1"
vars:
hostaddr: "server1"
username: "fedora"
imejdict: {
"linuxserver/plex": "latest",
"linuxserver/code-server": "latest",
"fedora": "latest",
"gitea/gitea": "latest",
"linuxserver/heimdall": "latest",
"p3terx/ariang": "latest",
"t0xic0der/supervisor-frontend-service": "v1.2.0b-arm64",
"t0xic0der/supervisor-driver-service": "v1.2.1b-arm64",
"linuxserver/rutorrent": "latest",
"ubuntu": "latest",
"t0xic0der/cdrsrv": "v3.9.2-centos8",
"p3terx/aria2-pro": "latest",
"portainer/portainer-ce": "latest",
"centos": "latest",
"alpine": "latest",
"golang": "alpine",
"linuxserver/thelounge": "latest"
}
tasks:
- name: "Setting the variables in the example template"
template:
src: "pulltemp.j2"
dest: "pulling_images_for_fedora_rpi4_homeserver.yml"
- name: "Pull listed Podman images from DockerHub"
hosts: "server1"
remote_user: "fedora"
tasks:
- name: "STEP 1 - Pull docker.io/linuxserver/plex:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/linuxserver/plex"
tag: "latest"
- name: "STEP 2 - Pull docker.io/linuxserver/code-server:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/linuxserver/code-server"
tag: "latest"
- name: "STEP 3 - Pull docker.io/fedora:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/fedora"
tag: "latest"
- name: "STEP 4 - Pull docker.io/gitea/gitea:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/gitea/gitea"
tag: "latest"
- name: "STEP 5 - Pull docker.io/linuxserver/heimdall:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/linuxserver/heimdall"
tag: "latest"
- name: "STEP 6 - Pull docker.io/p3terx/ariang:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/p3terx/ariang"
tag: "latest"
- name: "STEP 7 - Pull docker.io/t0xic0der/supervisor-frontend-service:v1.2.0b-arm64 from DockerHub"
containers.podman.podman_image:
name: "docker.io/t0xic0der/supervisor-frontend-service"
tag: "v1.2.0b-arm64"
- name: "STEP 8 - Pull docker.io/t0xic0der/supervisor-driver-service:v1.2.1b-arm64 from DockerHub"
containers.podman.podman_image:
name: "docker.io/t0xic0der/supervisor-driver-service"
tag: "v1.2.1b-arm64"
- name: "STEP 9 - Pull docker.io/linuxserver/rutorrent:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/linuxserver/rutorrent"
tag: "latest"
- name: "STEP 10 - Pull docker.io/ubuntu:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/ubuntu"
tag: "latest"
- name: "STEP 11 - Pull docker.io/t0xic0der/cdrsrv:v3.9.2-centos8 from DockerHub"
containers.podman.podman_image:
name: "docker.io/t0xic0der/cdrsrv"
tag: "v3.9.2-centos8"
- name: "STEP 12 - Pull docker.io/p3terx/aria2-pro:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/p3terx/aria2-pro"
tag: "latest"
- name: "STEP 13 - Pull docker.io/portainer/portainer-ce:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/portainer/portainer-ce"
tag: "latest"
- name: "STEP 14 - Pull docker.io/centos:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/centos"
tag: "latest"
- name: "STEP 15 - Pull docker.io/alpine:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/alpine"
tag: "latest"
- name: "STEP 16 - Pull docker.io/golang:alpine from DockerHub"
containers.podman.podman_image:
name: "docker.io/golang"
tag: "alpine"
- name: "STEP 17 - Pull docker.io/linuxserver/thelounge:latest from DockerHub"
containers.podman.podman_image:
name: "docker.io/linuxserver/thelounge"
tag: "latest"
- name: "Pull listed Podman images from DockerHub"
hosts: "{{ hostaddr }}"
remote_user: "{{ username }}"
tasks:
{% for keye, valu in imejdict.items() %}
- name: "STEP {{ loop.index }} - Pull docker.io/{{ keye }}:{{ valu }} from DockerHub"
containers.podman.podman_image:
name: "docker.io/{{ keye }}"
tag: "{{ valu }}"
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment