-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathadhoc-remove-mirror-stream-role.yml
92 lines (81 loc) · 3.18 KB
/
adhoc-remove-mirror-stream-role.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
# This ad-hoc playbook can be used to "revert" the ansible-mirror role that would fetch by default stream9 content
# Some sponsored mirrors don't have enough space for both, so we'll just remove the Stream 9 content (that is huge as it contains also src and debuginfo packages
# Before launching this playbook you'd need to ensure that mirror_stream_content is set to `False` in ansible inventory (and pushed) : we don't want to have automated ansible replay the settings the other way around
#
- hosts: "{{ mirror_host }}"
become: true
strategy: linear
gather_facts: false
vars_prompt:
- name: "mirror_host"
prompt: "[WARNING] Nodes to remove from mirror.stream.centos.org pool => "
private: no
handlers:
- import_tasks: handlers/main.yml
tasks:
- assert:
that:
- not mirror_stream_content
fail_msg: "{{ mirror_host }} seems to inherit mirror_stream_content boolean to True !"
- block:
- name: Updating PDNS GeoIP backend to remove stream roles
shell:
cmd: echo "update nodes set \"{{ item }}\"='false' where fqdn='{{ mirror_host }}';" |sqlite3 nodes.db
chdir: /var/lib/centos-infra/
with_items:
- mirror.stream
- rsync.stream
delegate_to: "{{ pdns_db_host }}"
- name: Regenerating .json backend for powerdns infra
shell:
cmd: ./gen_backend
chdir: /var/lib/centos-infra
delegate_to: "{{ pdns_db_host }}"
- name: Reloading directly powerdns zone on pdns nodes
command:
cmd: /var/lib/centos-pdns/backend_download
delegate_to: "{{ item }}"
with_items: "{{ groups['pdns-nodes'] }}"
tags:
- pdns
- name: Ensuring we don't actually try to fetch Stream content
become_user: centos
shell:
cmd: pkill -9 rsync ; /bin/true
tags:
- centos
- name: Cron job to rsync Stream 9 content from upstream node
cron:
name: "CentOS mirror.stream rsync job"
job: "/home/{{ mirror_local_user }}-scripts/rsync-stream-full {{ mirror_rsync_from }} > /dev/null 2>&1"
minute: "*/7"
user: "{{ mirror_local_user }}"
state: absent
tags:
- cron
- name: Cleaning up some files coming from role (not needed anymore)
file:
path: "{{ item }}"
state: absent
with_items:
- /etc/httpd/conf.d/11_mirror_stream.conf
- /etc/rsyncd.d/02_CentOS-Stream.conf
- /etc/rsyncd.d/03_centosstream.conf
notify:
- reload_httpd
- rebuild_rsyncd
- name: Reloading rsync/httpd if needed
meta: flush_handlers
- name: Removing stream content
file:
path: /home/centos-stream
state: absent
register: stream_content
tags:
- cleanup
- name: Reporting zabbix value
shell: zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k msync.stream.diff -o 5
when: stream_content is changed
tags:
- cleanup