WOW. I HAVE NOT THOUGHT OF THAT!!!111
@lemmy.ml
hum unfortunately either im doing something else wrong or its not working for me
---
- name: Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)
hosts: all
become: true
become_user: root
vars:
docker_packages:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
tasks:
- name: Ensure required packages are installed
apt:
name:
- ca-certificates
- curl
- gnupg
update_cache: yes
state: present
delegate_to: "{{ inventory_hostname }}"
- name: Ensure /etc/apt/keyrings exists
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
delegate_to: "{{ inventory_hostname }}"
- name: Get system architecture for Docker repo
ansible.builtin.command: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
delegate_to: "{{ inventory_hostname }}"
- name: Setup deb822 formatted repositorie
ansible.builtin.deb822_repository:
name: php
types: deb
uris: https://download.docker.com/linux/debian
components: stable
suites: "{{ ansible_distribution_release }}"
signed_by: https://download.docker.com/linux/debian/gpg
state: present
enabled: true
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
- name: Download Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/keyrings/docker.asc
mode: '0644'
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Check if GPG key exists
ansible.builtin.stat:
path: /etc/apt/keyrings/docker.asc
register: gpg_key_stat
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Show GPG key status
ansible.builtin.debug:
msg: "GPG key exists: {{ gpg_key_stat.stat.exists }}, Size: {{ gpg_key_stat.stat.size | default('N/A') }}"
- name: DEBUG - List keyrings directory
ansible.builtin.command: ls -lah /etc/apt/keyrings/
register: keyrings_list
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Show keyrings directory contents
ansible.builtin.debug:
var: keyrings_list.stdout_lines
- name: Add Docker APT repository (correct for Debian 13)
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_architecture.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
filename: docker
state: present
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Check if repo file exists
ansible.builtin.stat:
path: /etc/apt/sources.list.d/docker.list
register: repo_file_stat
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Show repo file status
ansible.builtin.debug:
msg: "Repo file exists: {{ repo_file_stat.stat.exists }}"
- name: DEBUG - Show repo file contents if exists
ansible.builtin.command: cat /etc/apt/sources.list.d/docker.list
register: repo_contents
when: repo_file_stat.stat.exists
failed_when: false
delegate_to: "{{ inventory_hostname }}"
- name: DEBUG - Display repo contents
ansible.builtin.debug:
var: repo_contents.stdout_lines
when: repo_file_stat.stat.exists
- name: Update apt cache after adding repo
apt:
update_cache: yes
delegate_to: "{{ inventory_hostname }}"
- name: Install Docker packages
apt:
name: "{{ docker_packages }}"
state: present
delegate_to: "{{ inventory_hostname }}"
- name: Enable & start Docker
service:
name: docker
state: started
enabled: yes
delegate_to: "{{ inventory_hostname }}"
PLAY [Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)] ***
TASK [Gathering Facts] *********************************************************
[1;35m[WARNING]: Host 'anytype.lab' is using the discovered Python interpreter at '/usr/bin/python3.13', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.19/reference_appendices/interpreter_discovery.html for more information.[0m
[0;32mok: [anytype.lab][0m
TASK [Ensure required packages are installed] **********************************
[0;33mchanged: [anytype.lab][0m
TASK [Ensure /etc/apt/keyrings exists] *****************************************
[0;32mok: [anytype.lab][0m
TASK [Get system architecture for Docker repo] *********************************
[0;36mskipping: [anytype.lab][0m
TASK [Setup deb822 formatted repositorie] **************************************
[0;33mchanged: [anytype.lab][0m
TASK [Download Docker GPG key] *************************************************
[0;33mchanged: [anytype.lab][0m
TASK [DEBUG - Check if GPG key exists] *****************************************
[0;32mok: [anytype.lab][0m
TASK [DEBUG - Show GPG key status] *********************************************
[0;32mok: [anytype.lab] => {[0m
[0;32m "msg": "GPG key exists: False, Size: N/A"[0m
[0;32m}[0m
TASK [DEBUG - List keyrings directory] *****************************************
[0;36mskipping: [anytype.lab][0m
TASK [DEBUG - Show keyrings directory contents] ********************************
[0;32mok: [anytype.lab] => {[0m
[0;32m "keyrings_list.stdout_lines": [][0m
[0;32m}[0m
TASK [Add Docker APT repository (correct for Debian 13)] ***********************
[0;33mchanged: [anytype.lab][0m
TASK [DEBUG - Check if repo file exists] ***************************************
[0;32mok: [anytype.lab][0m
TASK [DEBUG - Show repo file status] *******************************************
[0;32mok: [anytype.lab] => {[0m
[0;32m "msg": "Repo file exists: False"[0m
[0;32m}[0m
TASK [DEBUG - Show repo file contents if exists] *******************************
[0;36mskipping: [anytype.lab][0m
TASK [DEBUG - Display repo contents] *******************************************
[0;36mskipping: [anytype.lab][0m
TASK [Update apt cache after adding repo] **************************************
[0;33mchanged: [anytype.lab][0m
TASK [Install Docker packages] *************************************************
[0;31m[ERROR]: Task failed: Module failed: No package matching 'docker-ce' is available[0m
[0;31mOrigin: /tmp/ansible-webui/repositories/1_ansibleplaybooksrepo/playbooks/debian13docker.yml:112:7[0m
[0;31m[0m
[0;31m110 delegate_to: "{{ inventory_hostname }}"[0m
[0;31m111[0m
[0;31m112 - name: Install Docker packages[0m
[0;31m ^ column 7[0m
[0;31m[0m
[0;31mfatal: [anytype.lab]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}[0m
PLAY RECAP *********************************************************************
[0;31manytype.lab[0m : [0;32mok=12 [0m [0;33mchanged=5 [0m unreachable=0 [0;31mfailed=1 [0m [0;36mskipped=4 [0m rescued=0 ignored=0
thanks for sharing! and this works for you? as i said on my original post (on selfhosted channel), im new at ansible and i must be doing something stupid.
name: Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible) hosts: all become: true become_user: root
vars: docker_apks: - docker-ce - docker-ce-cli - containerd.io - docker-buildx-plugin - docker-compose-plugin docker_pre_apks: - gpg - ca-certificates - curl - gnupg docker_arch: amd64
tasks:
name: Install pre setup stuff ansible.builtin.apt: pkg: "{{ docker_pre_apks }}" update_cache: true state: present
name: Add gpg for docker repo ansible.builtin.apt_key: url: https://download.docker.com/linux/debian/gpg state: present when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
name: Copy up apt list ansible.builtin.apt_repository: repo: "deb [arch={{ docker_arch }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable" state: present filename: docker when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
name: Setup deb822 formatted repositorie ansible.builtin.deb822_repository: name: php types: deb uris: https://download.docker.com/linux/debian components: stable suites: "{{ ansible_distribution_release }}" signed_by: https://download.docker.com/linux/debian/gpg state: present enabled: true when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
name: Install docker ansible.builtin.apt: pkg: "{{ docker_apks }}" force_apt_get: yes update_cache: yes state: present
name: Start docker service ansible.builtin.service: name: docker enabled: yes state: started
this is the output:
PLAY [Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)] ***
TASK [Gathering Facts] ********************************************************* [1;35m[WARNING]: Host 'anytype.lab' is using the discovered Python interpreter at '/usr/bin/python3.13', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/... for more information.[0m [0;32mok: [anytype.lab][0m
TASK [Install pre setup stuff] ************************************************* [0;33mchanged: [anytype.lab][0m
TASK [Add gpg for docker repo] ************************************************* [0;36mskipping: [anytype.lab][0m
TASK [Copy up apt list] ******************************************************** [0;36mskipping: [anytype.lab][0m
TASK [Setup deb822 formatted repositorie] ************************************** [0;33mchanged: [anytype.lab][0m
TASK [Install docker] ********************************************************** [0;31m[ERROR]: Task failed: Module failed: No package matching 'docker-ce' is available[0m [0;31mOrigin: /tmp/ansible-webui/repositories/1_ansibleplaybooksrepo/playbooks/debian13docker.yml:54:7[0m [0;31m[0m [0;31m52 when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')[0m [0;31m53[0m [0;31m54 - name: Install docker[0m [0;31m ^ column 7[0m [0;31m[0m [0;31mfatal: [anytype.lab]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}[0m
PLAY RECAP ********************************************************************* [0;31manytype.lab[0m : [0;32mok=3 [0m [0;33mchanged=2 [0m unreachable=0 [0;31mfailed=1 [0m [0;36mskipped=2 [0m rescued=0 ignored=0
this is my inventory file:
root@ansible:/srv/ansible-webui/ansible/repositories/1_ansibleplaybooksrepo/inventory# cat hosts.yml all: children: lxc_containers: hosts: anytype.lab: ansible_host: 192.168.236.142 ansible_user: root ansible_ssh_private_key_file: ~/.ssh/id_ed25519
my workflow is not *completely* broken because i managed to get this workbook working:
name: install root ca certificate hosts: all gather_facts: yes
tasks:
name: Copy custom CA certificate copy: src: ../files/root_ca.crt dest: /usr/local/share/ca-certificates/root_ca.crt mode: '0644'
name: Update CA certificates command: update-ca-certificates register: ca_update
its of course a lot simpler...

PLAY [install root ca certificate] *********************************************
TASK [Gathering Facts] ********************************************************* [1;35m[WARNING]: Host 'ferdium.lab' is using the discovered Python interpreter at '/usr/bin/python3.13', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/... for more information.[0m [0;32mok: [ferdium.lab][0m
TASK [Copy custom CA certificate] ********************************************** [0;33mchanged: [ferdium.lab][0m
TASK [Update CA certificates] ************************************************** [0;33mchanged: [ferdium.lab][0m
PLAY RECAP ********************************************************************* [0;33mferdium.lab[0m : [0;32mok=3 [0m [0;33mchanged=2 [0m unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
it was a brand new host. the first (this above) playbook worked, but then the docker one didnt. so it doesnt seem to be a target host issue. both debian 13 lxc if that matters.
i dont see how, i have been doing this: https://www.manelrodero.com/... on maaany lxcs and they all work just fine!

docker_pre_apks:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- libssl-dev
- python3-cffi-backend
- python3-pip
- libffi-dev
- python3-setuptools
- python3-nacl
- python3-jsondiff
docker_apks:
- docker-ce
- docker-ce-cli
- containerd.io
still same result :(
---
- name: Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)
hosts: all
become: true
become_user: root
vars:
docker_pre_apks:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- libssl-dev
- python3-cffi-backend
- python3-pip
- libffi-dev
- python3-setuptools
- python3-nacl
- python3-jsondiff
docker_apks:
- docker-ce
- docker-ce-cli
- containerd.io
docker_arch: amd64
tasks:
- name: Install pre setup stuff
ansible.builtin.apt:
pkg: "{{ docker_pre_apks }}"
update_cache: true
state: present
- name: Add gpg for docker repo
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
- name: Copy up apt list
ansible.builtin.apt_repository:
repo: "deb [arch={{ docker_arch }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
filename: docker
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
- name: Setup deb822 formatted repositorie
ansible.builtin.deb822_repository:
name: php
types: deb
uris: https://download.docker.com/linux/debian
components: stable
suites: "{{ ansible_distribution_release }}"
signed_by: https://download.docker.com/linux/debian/gpg
state: present
enabled: true
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
- name: Install docker
ansible.builtin.apt:
pkg: "{{ docker_apks }}"
force_apt_get: yes
update_cache: yes
state: present
- name: Start docker service
ansible.builtin.service:
name: docker
enabled: yes
state: started
PLAY [Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)] ***
TASK [Gathering Facts] *********************************************************
[1;35m[WARNING]: Host 'anytype.lab' is using the discovered Python interpreter at '/usr/bin/python3.13', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.19/reference_appendices/interpreter_discovery.html for more information.[0m
[0;32mok: [anytype.lab][0m
TASK [Install pre setup stuff] *************************************************
[0;33mchanged: [anytype.lab][0m
TASK [Add gpg for docker repo] *************************************************
[0;36mskipping: [anytype.lab][0m
TASK [Copy up apt list] ********************************************************
[0;36mskipping: [anytype.lab][0m
TASK [Setup deb822 formatted repositorie] **************************************
[0;33mchanged: [anytype.lab][0m
TASK [Install docker] **********************************************************
[0;31m[ERROR]: Task failed: Module failed: No package matching 'docker-ce' is available[0m
[0;31mOrigin: /tmp/ansible-webui/repositories/1_ansibleplaybooksrepo/playbooks/debian13docker.yml:59:7[0m
[0;31m[0m
[0;31m57 when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')[0m
[0;31m58[0m
[0;31m59 - name: Install docker[0m
[0;31m ^ column 7[0m
[0;31m[0m
[0;31mfatal: [anytype.lab]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}[0m
PLAY RECAP *********************************************************************
[0;31manytype.lab[0m : [0;32mok=3 [0m [0;33mchanged=2 [0m unreachable=0 [0;31mfailed=1 [0m [0;36mskipped=2 [0m rescued=0 ignored=0
i have NO idea what i am doing wrong. this is new to me. but i personally learn better with practical examples rather than reading books and documentation. i thought setting up docker was simple enough to begin... i guess i was wrong.
thank you very much for your continued support!
i am not sure which file you are referring to. this is tree from /etc/apt:
root@anytype:/etc/apt# tree
.
|-- apt.conf.d
| |-- 01autoremove
| |-- 20listchanges
| `-- 70debconf
|-- auth.conf.d
|-- keyrings
|-- listchanges.conf
|-- listchanges.conf.d
|-- preferences.d
|-- sources.list.d
| `-- debian.sources
`-- trusted.gpg.d
|-- debian-archive-bookworm-automatic.asc
|-- debian-archive-bookworm-security-automatic.asc
|-- debian-archive-bookworm-stable.asc
|-- debian-archive-bullseye-automatic.asc
|-- debian-archive-bullseye-security-automatic.asc
|-- debian-archive-bullseye-stable.asc
|-- debian-archive-trixie-automatic.asc
|-- debian-archive-trixie-security-automatic.asc
`-- debian-archive-trixie-stable.asc
its been clear for awhile now that the script is doing pretty much nothing: because, as you can see: even the keyrings directory is empty, so its not even able the repo, hence it cant find docker-ce. im not sure where it fails. if downloading the asc file, dearmoring, adding repo..
as you can see im running as root by the way, so no need to become.
how do you suggest i debug this? sorry for my total lack of knowledge.
my latest / current version doesnt have that anymore (ive been through a lot of constant revisions...)
---
- name: Install Docker Engine and Docker Compose on Debian (Ansible WebUI compatible)
hosts: all
become: true
become_user: root
vars:
docker_pre_apks:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- libssl-dev
- python3-cffi-backend
- python3-pip
- libffi-dev
- python3-setuptools
- python3-nacl
- python3-jsondiff
docker_apks:
- docker-ce
- docker-ce-cli
- containerd.io
docker_arch: amd64
tasks:
- name: Install pre setup stuff
ansible.builtin.apt:
pkg: "{{ docker_pre_apks }}"
update_cache: true
state: present
- name: Add gpg for docker repo
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
- name: Copy up apt list
ansible.builtin.apt_repository:
repo: "deb [arch={{ docker_arch }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
filename: docker
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '12')
- name: Setup deb822 formatted repositorie
ansible.builtin.deb822_repository:
name: php
types: deb
uris: https://download.docker.com/linux/debian
components: stable
suites: "{{ ansible_distribution_release }}"
signed_by: https://download.docker.com/linux/debian/gpg
state: present
enabled: true
when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
- name: Install docker
ansible.builtin.apt:
pkg: "{{ docker_apks }}"
force_apt_get: yes
update_cache: yes
state: present
- name: Start docker service
ansible.builtin.service:
name: docker
enabled: yes
state: started
as a reminder: this is run (unsuccessfully) through ansible web-ui
while that could be an issue, im confused the same setup was able to run a (simplier) nother playbook

- name: install root ca certificate
hosts: all
gather_facts: yes
tasks:
- name: Copy custom CA certificate
copy:
src: ../files/root_ca.crt
dest: /usr/local/share/ca-certificates/root_ca.crt
mode: '0644'
- name: Update CA certificates
command: update-ca-certificates
register: ca_update
im not making sense of this
wow that would be extremely kind of you!! im based in spain. im just one hour ahead of you. PMing you my google address
v29 is a big update https://www.reddit.com/... ive made lxc config changes, and id like to have everything on the same update lvl. no have some apps with a lxc config because of official repos, and some other ansible powered with a lower version. i like to have everything on the same update level so i dont go crazy updating my homelab. besides, this would be "dodging" the problem. in my ansible training, id like to be able to add a repo to a given server.
yeah thats the thing - its apparently not doing ****. no keyring, no repo
but it is connecting to the remote server. it does say on the log anytype.lab; which is my target server, and its selected from the correct inventory file:

i know it must be something terribly stupid. but i just cant put my finger on it
thanks for using Leebra!
go to feed...