ansible/roles/docker/tasks/setup_gpg_key.yml
ilia e05b3aa0d5 Update ansible.cfg and auto-fallback script for improved connectivity handling
- Modify ansible.cfg to increase SSH connection retries from 2 to 3 and add a connection timeout setting for better reliability.
- Enhance auto-fallback.sh script to provide detailed feedback during IP connectivity tests, including clearer status messages for primary and fallback IP checks.
- Update documentation to reflect changes in connectivity testing and fallback procedures.

These updates improve the robustness of the connectivity testing process and ensure smoother operations during IP failover scenarios.
2025-09-16 23:00:32 -04:00

46 lines
1.4 KiB
YAML

---
- name: Check if Docker GPG key exists and is correct
ansible.builtin.shell: |
if [ -f /etc/apt/keyrings/docker.gpg ]; then
if file /etc/apt/keyrings/docker.gpg | grep -q "PGP"; then
echo "correct_key"
else
echo "wrong_key"
fi
else
echo "not_exists"
fi
register: docker_key_check
failed_when: false
- name: Remove incorrect Docker GPG key
ansible.builtin.file:
path: /etc/apt/keyrings/docker.gpg
state: absent
become: true
when: docker_key_check.stdout == "wrong_key"
- name: Download Docker's official GPG key only if needed
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /tmp/docker.gpg
mode: '0644'
when: docker_key_check.stdout in ["not_exists", "wrong_key"]
- name: Convert and install Docker GPG key only if needed
ansible.builtin.shell: gpg --dearmor < /tmp/docker.gpg > /etc/apt/keyrings/docker.gpg
changed_when: false
when: docker_key_check.stdout in ["not_exists", "wrong_key"]
- name: Set permissions on Docker GPG key only if needed
ansible.builtin.file:
path: /etc/apt/keyrings/docker.gpg
mode: '0644'
when: docker_key_check.stdout in ["not_exists", "wrong_key"]
- name: Clean up temporary GPG key file
ansible.builtin.file:
path: /tmp/docker.gpg
state: absent
when: docker_key_check.stdout in ["not_exists", "wrong_key"]