Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mirror list files for apt #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,21 @@
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
when: "ansible_distribution == 'Linux Mint'"
- 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)
8 changes: 8 additions & 0 deletions roles/common/tasks/mint_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions roles/common/templates/mint-mirrors.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for mirror in mint_mirrors %}
{{ mirror }}
{% endfor %}
20 changes: 7 additions & 13 deletions roles/common/templates/mint.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions roles/common/templates/ubuntu-mirrors.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for mirror in ubuntu_mirrors %}
{{ mirror }}
{% endfor %}
12 changes: 5 additions & 7 deletions roles/common/templates/ubuntu.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions roles/common/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down