andrewrothstein / ansible_restic

MIT License
4 stars 1 forks source link

Role fails at installing unzip #1

Open anarion80 opened 3 months ago

anarion80 commented 3 months ago

Hello.

Recently the role started failing at installing unarchive with the error message "No package matching 'unzip' is available" This is while using Molecule tests on geerlingguy/docker-ubuntu2204-ansible:latest image.

More logs:

INFO     Running default > dependency
ansible-galaxy [core 2.14.1]
  config file = None
  configured module search path = ['/home/anarion/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/anarion/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/anarion/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/anarion/.local/bin/ansible-galaxy
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
No config file found; using defaults
Reading requirement file at '/home/anarion/repos/ansible-nas/roles/restic/main/requirements.yml'
found role {'name': 'andrewrothstein.restic', 'version': '', 'scm': None} in yaml file
Starting galaxy role install process
Processing role andrewrothstein.restic 
Opened /home/anarion/.ansible/galaxy_token
- downloading role 'restic', owned by andrewrothstein
- downloading role from https://github.com/andrewrothstein/ansible_restic/archive/v1.2.0.tar.gz
- extracting andrewrothstein.restic to /home/anarion/.cache/molecule/restic/default/roles/andrewrothstein.restic
- andrewrothstein.restic (v1.2.0) was installed successfully
- adding dependency: andrewrothstein.unarchivedeps (3.0.2)
Processing role andrewrothstein.unarchivedeps 
- downloading role 'unarchivedeps', owned by andrewrothstein
- downloading role from https://github.com/andrewrothstein/ansible-unarchivedeps/archive/3.0.2.tar.gz
- extracting andrewrothstein.unarchivedeps to /home/anarion/.cache/molecule/restic/default/roles/andrewrothstein.unarchivedeps
- andrewrothstein.unarchivedeps (3.0.2) was installed successfully

.
.
.
.

TASK [Installing andrewrothstein.unarchivedeps] ********************************
task path: /home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.restic/tasks/main.yml:30

TASK [andrewrothstein.unarchivedeps : Resolve platform specific vars] **********
task path: /home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.unarchivedeps/tasks/main.yml:2
ok: [instance] => (item=/home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.unarchivedeps/vars/Debian.yml) => {
    "ansible_facts": {
        "unarchivedeps_xz_pkgs": [
            "xz-utils"
        ]
    },
    "ansible_included_var_files": [
        "/home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.unarchivedeps/vars/Debian.yml"
    ],
    "ansible_loop_var": "item",
    "changed": false,
    "item": "/home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.unarchivedeps/vars/Debian.yml"
}

TASK [andrewrothstein.unarchivedeps : Install unarchive ansible module required OS pkgs...] ***
task path: /home/anarion/.cache/ansible-compat/6affe8/roles/andrewrothstein.unarchivedeps/tasks/main.yml:13
The full traceback is:
  File "/tmp/ansible_ansible.legacy.apt_payload_avup23g1/ansible_ansible.legacy.apt_payload.zip/ansible/modules/apt.py", line 526, in package_status
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 283, in __getitem__
    raise KeyError('The cache has no package named %r' % key)
fatal: [instance]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_change_held_packages": false,
            "allow_downgrade": false,
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "clean": false,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "fail_on_autoremove": false,
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "lock_timeout": 60,
            "name": [
                "unzip",
                "gzip",
                "bzip2",
                "tar",
                "xz-utils"
            ],
            "only_upgrade": false,
            "package": [
                "unzip",
                "gzip",
                "bzip2",
                "tar",
                "xz-utils"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    },
    "msg": "No package matching 'unzip' is available"
}
<instance> ESTABLISH DOCKER CONNECTION FOR USER: root
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'echo ~ && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975 `" && echo ansible-tmp-1717659527.7499976-1066482-17174767777975="` echo /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975 `" ) && sleep 0\'']
Using module file /home/anarion/.local/lib/python3.10/site-packages/ansible/modules/apt.py
<instance> PUT /home/anarion/.ansible/tmp/ansible-local-1065301io2_uslp/tmp84347r4f TO /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975/AnsiballZ_apt.py
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975/ /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975/AnsiballZ_apt.py && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'sudo -H -S -n  -u root /bin/sh -c \'"\'"\'echo BECOME-SUCCESSl ; /usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975/AnsiballZ_apt.py\'"\'"\' && sleep 0\'']
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1717659527.7499976-1066482-17174767777975/ > /dev/null 2>&1 && sleep 0'"]
ansible [core 2.14.1]
  config file = None
  configured module search path = ['/home/anarion/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/anarion/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/anarion/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/anarion/.local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
ansible-galaxy [core 2.14.1]
  config file = None
  configured module search path = ['/home/anarion/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/anarion/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/anarion/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/anarion/.local/bin/ansible-galaxy
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

You can see the details as well here: https://github.com/anarion80/ansible-nas/actions/runs/9392452531/job/25866747029

anarion80 commented 3 months ago

My playbook works after I update apt cache before including the role:

    - name: Update apt-cache
      ansible.builtin.apt:
        update_cache: yes
        cache_valid_time: 3600
      register: result
      until: result is succeeded

but still, I think this should be added to the role itself.