From 35611e1b737e1fd03d5a9cb9644a9fb2d7c833d9 Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Mon, 6 Sep 2021 09:39:44 -0400 Subject: [PATCH] Try using mirror:// URI --- roles/common/tasks/main.yml | 9 ++++++++- roles/common/tasks/mint_only.yml | 8 ++++++++ roles/common/tasks/ubuntu_only.yml | 2 +- roles/common/templates/mint-mirrors.j2 | 3 +++ roles/common/templates/mint.j2 | 20 +++++++------------- roles/common/templates/ubuntu-mirrors.j2 | 3 +++ roles/common/templates/ubuntu.j2 | 12 +++++------- roles/common/vars/main.yml | 4 ++++ 8 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 roles/common/templates/mint-mirrors.j2 create mode 100644 roles/common/templates/ubuntu-mirrors.j2 diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 74e98bef..6bad15f3 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -57,6 +57,14 @@ dest: "{{ wrapper_desktop_file_path }}/jmucs_config.desktop" mode: "0755" +- name: Set Ubuntu mirrors + template: + src: ubuntu-mirrors.j2 + dest: "{{ mirror_file_path.ubuntu }}" + mode: "0644" + owner: root + group: root + - include_tasks: ubuntu_only.yml when: "ansible_distribution == 'Ubuntu'" - include_tasks: mint_only.yml @@ -66,5 +74,4 @@ update_cache: yes register: apt_update retries: 100 - failed_when: apt_update.failed and 'Unable to connect to' not in apt_update.stderr until: apt_update is success or ('Failed to lock apt for exclusive operation' not in apt_update.msg and '/var/lib/dpkg/lock' not in apt_update.msg) diff --git a/roles/common/tasks/mint_only.yml b/roles/common/tasks/mint_only.yml index 2db62e81..9613ace8 100644 --- a/roles/common/tasks/mint_only.yml +++ b/roles/common/tasks/mint_only.yml @@ -17,6 +17,14 @@ group: root - name: Set Linux Mint mirrors + template: + src: mint-mirrors.j2 + dest: "{{ mirror_file_path.mint }}" + owner: root + group: root + mode: "0644" + when: "ansible_architecture == 'x86_64'" +- name: Set Linux Mint sources template: src: mint.j2 dest: /etc/apt/sources.list.d/official-package-repositories.list diff --git a/roles/common/tasks/ubuntu_only.yml b/roles/common/tasks/ubuntu_only.yml index 040cd331..437e9ba1 100644 --- a/roles/common/tasks/ubuntu_only.yml +++ b/roles/common/tasks/ubuntu_only.yml @@ -1,7 +1,7 @@ --- # tasks file for Ubuntu -- name: Set Ubuntu mirrors +- name: Set Ubuntu sources template: src: ubuntu.j2 dest: /etc/apt/sources.list diff --git a/roles/common/templates/mint-mirrors.j2 b/roles/common/templates/mint-mirrors.j2 new file mode 100644 index 00000000..ff2e84d6 --- /dev/null +++ b/roles/common/templates/mint-mirrors.j2 @@ -0,0 +1,3 @@ +{% for mirror in mint_mirrors %} +{{ mirror }} +{% endfor %} diff --git a/roles/common/templates/mint.j2 b/roles/common/templates/mint.j2 index 339edb0d..734f320c 100644 --- a/roles/common/templates/mint.j2 +++ b/roles/common/templates/mint.j2 @@ -4,20 +4,14 @@ # Place modifications in another file in /etc/apt/sources.list.d/ with a .list # file extension. -{% for mirror in ubuntu_mirrors %} -# Upstream Ubuntu sources for {{ mirror }} -deb {{ mirror }} {{ ubuntu_release }} main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-updates main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-backports main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-security main restricted universe multiverse +# Ubuntu sources +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }} main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-updates main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-backports main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-security main restricted universe multiverse -{% endfor %} - -{% for mirror in mint_mirrors %} -# Mint sources for {{ mirror }} -deb {{ mirror }} {{ ansible_distribution_release }} main upstream import backport - -{% endfor %} +# Mint sources +deb mirror+file://{{ mirror_file_path.mint }} {{ ansible_distribution_release }} main upstream import backport # Parter repository (necessary for optional media codecs) -- not mirrored deb http://archive.canonical.com/ubuntu {{ ubuntu_release }} partner diff --git a/roles/common/templates/ubuntu-mirrors.j2 b/roles/common/templates/ubuntu-mirrors.j2 new file mode 100644 index 00000000..a08ff051 --- /dev/null +++ b/roles/common/templates/ubuntu-mirrors.j2 @@ -0,0 +1,3 @@ +{% for mirror in ubuntu_mirrors %} +{{ mirror }} +{% endfor %} diff --git a/roles/common/templates/ubuntu.j2 b/roles/common/templates/ubuntu.j2 index 88eca3e4..d97f8322 100644 --- a/roles/common/templates/ubuntu.j2 +++ b/roles/common/templates/ubuntu.j2 @@ -4,13 +4,11 @@ # Place modifications in another file in /etc/apt/sources.list.d/ with a .list # file extension. -{% for mirror in ubuntu_mirrors %} -deb {{ mirror }} {{ ubuntu_release }} main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-updates main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-backports main restricted universe multiverse -deb {{ mirror }} {{ ubuntu_release }}-security main restricted universe multiverse - -{% endfor %} +# Ubuntu sources +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }} main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-updates main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-backports main restricted universe multiverse +deb mirror+file://{{ mirror_file_path.ubuntu }} {{ ubuntu_release }}-security main restricted universe multiverse # Parter repository (necessary for optional media codecs) -- not mirrored deb http://archive.canonical.com/ubuntu {{ ubuntu_release }} partner diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml index 670e10a0..6d33ccea 100644 --- a/roles/common/vars/main.yml +++ b/roles/common/vars/main.yml @@ -8,6 +8,10 @@ mint_mirrors: - "https://mirror.cs.jmu.edu/pub/linuxmint/packages" - "http://packages.linuxmint.com" +mirror_file_path: + mint: /etc/apt/mint-mirrors.txt + ubuntu: /etc/apt/ubuntu-mirrors.txt + global_base_path: "/opt" global_profile_path: "{{ global_base_path }}/csvmprofile"