diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 7b8c418d..26eeabd7 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 + ansible.builtin.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 @@ -64,5 +72,6 @@ - name: Refresh apt cache ansible.builtin.apt: update_cache: yes - changed_when: false - ignore_errors: yes + register: apt_update + retries: 100 + 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 7aef499f..e6e6d572 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 + ansible.builtin.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 ansible.builtin.template: src: mint.j2 dest: /etc/apt/sources.list.d/official-package-repositories.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"