Skip to content

Commit

Permalink
apt_repository: Update PPA URL to point to HTTPS (ansible#82599)
Browse files Browse the repository at this point in the history
Fixes: ansible#82463

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored Feb 7, 2024
1 parent b6a89bf commit e78be30
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/ppa_https.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- apt_repository - update PPA URL to point to https URL (https://github.com/ansible/ansible/issues/82463).
3 changes: 2 additions & 1 deletion lib/ansible/modules/apt_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class UbuntuSourcesList(SourcesList):
# prefer api.launchpad.net over launchpad.net/api
# see: https://github.com/ansible/ansible/pull/81978#issuecomment-1767062178
LP_API = 'https://api.launchpad.net/1.0/~%s/+archive/%s'
PPA_URI = 'https://ppa.launchpadcontent.net'

def __init__(self, module):
self.module = module
Expand Down Expand Up @@ -496,7 +497,7 @@ def _expand_ppa(self, path):
except IndexError:
ppa_name = 'ppa'

line = 'deb http://ppa.launchpad.net/%s/%s/ubuntu %s main' % (ppa_owner, ppa_name, self.codename)
line = 'deb %s/%s/%s/ubuntu %s main' % (self.PPA_URI, ppa_owner, ppa_name, self.codename)
return line, ppa_owner, ppa_name

def _key_already_exists(self, key_fingerprint):
Expand Down
43 changes: 42 additions & 1 deletion test/integration/targets/apt_repository/tasks/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- set_fact:
test_ppa_name: 'ppa:git-core/ppa'
test_ppa_filename: 'git-core'
test_ppa_spec: 'deb http://ppa.launchpad.net/git-core/ppa/ubuntu {{ansible_distribution_release}} main'
test_ppa_spec: 'deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu {{ansible_distribution_release}} main'
test_ppa_key: 'E1DF1F24' # http://keyserver.ubuntu.com:11371/pks/lookup?search=0xD06AAF4C11DAB86DF421421EFE6B20ECA7AD98A1&op=index

- name: show python version
Expand Down Expand Up @@ -288,6 +288,47 @@
apt: pkg=local-apt-repository state=absent purge=yes

#
# TEST: PPA HTTPS URL
#
- name: Add PPA using HTTPS URL
apt_repository:
repo: 'ppa:deadsnakes'
filename: 'deadsnakes'
state: present
register: result

- name: Check if PPA using HTTPS URL is added
assert:
that:
- 'result.changed'
- 'result.state == "present"'
- 'result.repo == "ppa:deadsnakes"'

- name: 'examine source file'
stat:
path: '/etc/apt/sources.list.d/deadsnakes.list'
register: source_file

- name: 'assert source file exists'
assert:
that:
- 'source_file.stat.exists == True'

- name: Check if the PPA URL
shell: "grep 'https://ppa.launchpadcontent.net' /etc/apt/sources.list.d/deadsnakes.list"
register: r

- name: Test if PPA URL points to https URL
assert:
that:
- r.changed
- "'https://ppa.launchpadcontent.net' in r.stdout"

- name: Remove PPA file
file:
path: '/etc/apt/sources.list.d/deadsnakes.list'
state: absent
#
# TEARDOWN
#
- import_tasks: 'cleanup.yml'

0 comments on commit e78be30

Please sign in to comment.