Skip to content

Commit

Permalink
python: cleanup old deadsnakes source files and revert to using ansib…
Browse files Browse the repository at this point in the history
…le.builtin.apt_repository
  • Loading branch information
saltydk committed Jun 27, 2024
1 parent bf87fc7 commit 08e8389
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions roles/python/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,32 @@
msg: "This role is only for Ubuntu 20.04 and 22.04 when installing Python 3.12"
when: ansible_distribution_version is version('24.04', '==') and python_version == "3.12"

- name: Remove old repository entry
ansible.builtin.apt_repository:
repo: "{{ item }}"
filename: "deadsnakes"
update_cache: true
- name: Identify apt source files
ansible.builtin.find:
paths: /etc/apt/sources.list.d/
recurse: no
register: apt_source_files

- name: Check if file contains 'deadsnakes'
ansible.builtin.slurp:
path: "{{ item.path }}"
register: file_contents
loop: "{{ apt_source_files.files }}"

- name: Remove apt source files containing 'deadsnakes'
ansible.builtin.file:
path: "{{ item.item.path }}"
state: absent
loop:
- "{{ python_apt_repo_url_old }}"
- "{{ python_apt_repo_url_old2 }}"
loop: "{{ file_contents.results }}"
when: "'deadsnakes' in item.content | b64decode"

- name: Update APT package index
ansible.builtin.apt:
update_cache: yes

- name: Add deadsnakes/ppa
ansible.builtin.shell: add-apt-repository ppa:deadsnakes/ppa --yes
ansible.builtin.apt_repository:
repo: ppa:deadsnakes/ppa
register: result
retries: "{{ ansible_retry_count if (not continuous_integration) else ansible_retry_count_ci }}"
delay: 10
Expand Down

0 comments on commit 08e8389

Please sign in to comment.