forked from redhat-nfvpe/toad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rhel_mirror_sync.yml
74 lines (61 loc) · 2.4 KB
/
rhel_mirror_sync.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
- block:
- name: Install needed packages for reposync
package:
name: "{{ item }}"
state: present
with_items:
- createrepo
- vsftpd
- yum-utils
- name: Enable vsftpd service
service:
name: vsftpd
enabled: yes
state: started
- name: Install needed packaged for firewalld
package:
name: "{{ item }}"
state: present
with_items:
- python-firewall
- name: Check if iptables is running
command: systemctl is-active iptables
ignore_errors: yes
changed_when: false
register: iptables_service_status
- name: Check if firewalld is running
command: systemctl is-active firewalld
ignore_errors: yes
changed_when: false
register: firewalld_service_status
- name: Open firewall port for input ftp (iptables)
command: "iptables -A INPUT -p tcp -m tcp --dport 21 -m conntrack --ctstate ESTABLISHED,NEW -j ACCEPT -m comment --comment 'Allow ftp connections to port 21'"
when: iptables_service_status.stdout == 'active'
- name: Open firewall port for output ftp (iptables)
command: "iptables -A INPUT -p tcp -m tcp --dport 21 -m conntrack --ctstate ESTABLISHED,NEW -j ACCEPT -m comment --comment 'Allow ftp connections from port 21'"
when: iptables_service_status.stdout == 'active'
- name: Open firewall port for ftp (firewall)
firewalld:
service: ftp
permanent: true
state: enabled
immediate: true
when: firewalld_service_status.stdout == 'active'
- name: Check if repo already exists
stat: path=/var/ftp/pub/osp_repo
register: repo_already_exists
- name: Create temporary directory for mirror
file:
path: /var/ftp/pub/osp_repo
state: directory
mode: "0755"
when: repo_already_exists.stat.exists == False
- name: Mirror repository locally
shell: "reposync -l -n -p /var/ftp/pub/osp_repo/ > /dev/null"
when: repo_already_exists.stat.exists == False
- name: Create repositories from local mirror
shell: "for DIR in `find /var/ftp/pub/osp_repo -maxdepth 1 -mindepth 1 -type d`; do createrepo $DIR; done; > /dev/null"
when: repo_already_exists.stat.exists == False
- name: Execute repository creation script
script: "./scripts/create_repo.sh osp_repo"
become: true