Skip to content

Commit 029bff1

Browse files
committed
allow choose apt mirrors
1 parent 3dedbf2 commit 029bff1

File tree

8 files changed

+43
-5
lines changed

8 files changed

+43
-5
lines changed

config/defaults/version-large.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ system_default:
194194
reboot_timeout: 300 # wait 5 minutes max when rebooting the system
195195
apt: # The apt sections to use,
196196
sections: [ main ] # contrib and non-free not activated by default
197+
mirror: deb.debian.org # package mirror to use
197198

198199
# Administration settings
199200
# the user below is automatically added to the sudo group

config/defaults/version-medium.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ system_default:
189189
reboot_timeout: 300 # wait 5 minutes max when rebooting the system
190190
apt: # The apt sections to use,
191191
sections: [ main ] # contrib and non-free not activated by default
192+
mirror: deb.debian.org # package mirror to use
192193

193194
# Administration settings
194195
# the user below is automatically added to the sudo group

config/defaults/version-mini.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ system_default:
179179
reboot_timeout: 300 # wait 5 minutes max when rebooting the system
180180
apt: # The apt sections to use,
181181
sections: [ main ] # contrib and non-free not activated by default
182+
mirror: deb.debian.org # package mirror to use
182183

183184
# Administration settings
184185
# the user below is automatically added to the sudo group

config/defaults/version-small.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ system_default:
189189
reboot_timeout: 300 # wait 5 minutes max when rebooting the system
190190
apt: # The apt sections to use,
191191
sections: [ main ] # contrib and non-free not activated by default
192+
mirror: deb.debian.org # package mirror to use
192193

193194
# Administration settings
194195
# the user below is automatically added to the sudo group

config/samples/system-minimal.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ system:
5858
release: bookworm
5959
devel: false
6060
debug: false
61-
61+
apt:
62+
mirror: deb.debian.org
6263

6364
###############################################################################
6465
# If you are using Gandi, you can enter an API key here

docs/30-define-your-config.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If you are planning to work with multiple domains, jump to the next section dire
6868
Once you have chosen your flavour, you need to copy the configuration sample, to create yours:
6969

7070
```sh
71-
cp config/samples/minimal.yml config/system.yml
71+
cp config/samples/system-minimal.yml config/system.yml
7272
```
7373

7474
You also need to copy the inventory file for Ansible.
@@ -79,10 +79,10 @@ cp config/samples/hosts.yml config/hosts.yml
7979

8080
### Working with multiple domains
8181

82-
To work with multiple domains, uses these commands instead, by adjusting `<domain-name>`:
82+
To work with multiple domains, use these commands instead, by adjusting `<domain-name>`:
8383

8484
```sh
85-
cp config/samples/minimal.yml config/system-<domain-name>.yml
85+
cp config/samples/system-minimal.yml config/system-<domain-name>.yml
8686
```
8787

8888
Same for the inventory file for Ansible:
@@ -91,7 +91,7 @@ Same for the inventory file for Ansible:
9191
cp config/samples/hosts.yml config/hosts-<domain-name>.yml
9292
```
9393

94-
The inventory should contains this:
94+
The inventory should contain this:
9595

9696
```yml
9797
all:
@@ -265,6 +265,8 @@ system:
265265
release: bookworm
266266
devel: false
267267
debug: false
268+
apt:
269+
mirror: deb.debian.org
268270
```
269271
270272
#### DNS provider

roles/bootstrap/tasks/check/apt.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
---
22

3+
- name: Check apt mirror is valid for us
4+
changed_when: false
5+
failed_when: not system_apt_mirror_release_match.rc == 0
6+
register: system_apt_mirror_release_match
7+
ansible.builtin.shell: >-
8+
wget --no-config -qO - --wait=3 --random-wait \
9+
"http://{{ system.apt.mirror }}/debian/dists/{{ distribution_release }}/Release" \
10+
|egrep -q "^Codename[:][[:blank:]]+{{ distribution_release }}"
11+
loop:
12+
- "{{ system.release }}"
13+
- "{{ system.release }}-updates"
14+
- "{{ system.release }}-backports"
15+
loop_control:
16+
loop_var: distribution_release
17+
318
- name: Check if we can run apt update without error
419
ansible.builtin.apt:
520
update_cache: true

roles/bootstrap/tasks/install/apt.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
ansible.builtin.set_fact:
77
sections: '{{ system.apt.sections | join(" ") }}'
88

9+
10+
- name: Check apt mirror is valid for us
11+
changed_when: false
12+
failed_when: not system_apt_mirror_release_match.rc == 0
13+
register: system_apt_mirror_release_match
14+
ansible.builtin.shell: >-
15+
wget --no-config -qO - --wait=3 --random-wait \
16+
"http://{{ system.apt.mirror }}/debian/dists/{{ distribution_release }}/Release" \
17+
|egrep -q "^Codename[:][[:blank:]]+{{ distribution_release }}"
18+
loop:
19+
- "{{ system.release }}"
20+
- "{{ system.release }}-updates"
21+
- "{{ system.release }}-backports"
22+
loop_control:
23+
loop_var: distribution_release
24+
925
- name: Initialise default repositories
1026
register: repositories
1127
ansible.builtin.template:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy