[–] [S] 1 point 11 months ago (2 children)

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

  • source
  • parent
  • context
  • [–] 2 points 11 months ago

    Well I can't see either docker or my missed named php file in that, so would concur that it's not working.

    Your playbooks look to be run as root, so it should have placed a file or 2.

    Will re-read all the comments and see if I can spot anything

  • source
  • parent
  • context
  • [–] [S] 1 point 11 months ago (5 children)

    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.

  • source
  • parent
  • context
  • [–] 2 points 11 months ago (6 children)

    How very odd, as root can you try some things?

    1. Can you cat the apt config? File is /etc/apt/sources.d/php not sure of the file extension, but should have the config to collect docker

    Also if you run apt install docker-ce does it give you any better errors?

  • source
  • parent
  • context
  • [–] [S] 1 point 11 months ago (7 children)

    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] *********************************************************
    [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.
    ok: [anytype.lab]
    
    TASK [Install pre setup stuff] *************************************************
    changed: [anytype.lab]
    
    TASK [Add gpg for docker repo] *************************************************
    skipping: [anytype.lab]
    
    TASK [Copy up apt list] ********************************************************
    skipping: [anytype.lab]
    
    TASK [Setup deb822 formatted repositorie] **************************************
    changed: [anytype.lab]
    
    TASK [Install docker] **********************************************************
    [ERROR]: Task failed: Module failed: No package matching 'docker-ce' is available
    Origin: /tmp/ansible-webui/repositories/1_ansibleplaybooksrepo/playbooks/debian13docker.yml:59:7
    
    57       when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
    58
    59     - name: Install docker
             ^ column 7
    
    fatal: [anytype.lab]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}
    
    PLAY RECAP *********************************************************************
    anytype.lab                : ok=3    changed=2    unreachable=0    failed=1    skipped=2    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.

  • source
  • parent
  • context
  • [–] 2 points 11 months ago (8 children)

    Oh, thats very odd. Have tested on lxc and runs fine, the only thing I can see that could trip it up is the list of packages.

    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
    
  • source
  • parent
  • context
  • [–] [S] 1 point 11 months ago (11 children)

    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.

    this is your yaml very slightly adapted:

    ***
    - 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] *********************************************************
    [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.
    ok: [anytype.lab]
    
    TASK [Install pre setup stuff] *************************************************
    changed: [anytype.lab]
    
    TASK [Add gpg for docker repo] *************************************************
    skipping: [anytype.lab]
    
    TASK [Copy up apt list] ********************************************************
    skipping: [anytype.lab]
    
    TASK [Setup deb822 formatted repositorie] **************************************
    changed: [anytype.lab]
    
    TASK [Install docker] **********************************************************
    [ERROR]: Task failed: Module failed: No package matching 'docker-ce' is available
    Origin: /tmp/ansible-webui/repositories/1_ansibleplaybooksrepo/playbooks/debian13docker.yml:54:7
    
    52       when: (ansible_distribution == 'Debian' and ansible_distribution_major_version >= '13')
    53
    54     - name: Install docker
             ^ column 7
    
    fatal: [anytype.lab]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}
    
    PLAY RECAP *********************************************************************
    anytype.lab                : ok=3    changed=2    unreachable=0    failed=1    skipped=2    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] *********************************************************
    [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/ansible-core/2.19/reference_appendices/interpreter_discovery.html for more information.
    ok: [ferdium.lab]
    
    TASK [Copy custom CA certificate] **********************************************
    changed: [ferdium.lab]
    
    TASK [Update CA certificates] **************************************************
    changed: [ferdium.lab]
    
    PLAY RECAP *********************************************************************
    ferdium.lab                : ok=3    changed=2    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.

  • source
  • parent
  • context