-
Notifications
You must be signed in to change notification settings - Fork 0
/
yum_repo.yml
executable file
·95 lines (80 loc) · 1.97 KB
/
yum_repo.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
93
94
95
---
- hosts: yum-server
user: ec2-user
become: yes
tasks:
- name: install required packages
yum:
name:
- createrepo
- httpd
state: present
- name: Creates directory
ansible.builtin.file:
path: /mnt/localrepo
state: directory
- name: Download packages but do not install it #You can also copy packages from ISO file
yum:
name:
- tree
- zip
state: latest
download_only: true
download_dir: /mnt/localrepo
- name: Create localrepo.repo
shell: |
cat << EOF > /etc/yum.repos.d/localrepo.repo
[localrepo]
name=Localrepo Repository
baseurl=file:///mnt/localrepo
gpgcheck=0
enabled=1
EOF
- name: execute createrepo
shell: |
createrepo -v /mnt/localrepo
yum clean all
yum repolist
yum update -y
- name: disable SELinux
command: setenforce 0
ignore_errors: yes
- name: disable SELinux on reboot
selinux:
state: disabled
ignore_errors: yes
- name: Copy httpd_conf.py on YUM repo server
ansible.builtin.copy:
src: httpd_conf.py
dest: ~/
mode: 0777
- name: Run httpd_conf.py using an executable in a system path
ansible.builtin.script: httpd_conf.py
args:
executable: python
- name: Remove welcome page
ansible.builtin.file:
path: /etc/httpd/conf.d/welcome.conf
state: absent
- name: Restart httpd
service:
name: httpd
state: restarted
enabled: yes
###############################
###############################
- hosts: yum-client
user: ec2-user
become: yes
tasks:
- name: Create localrepo.repo on client machine
shell: |
cat << EOF > /etc/yum.repos.d/localrepo.repo
[localrepo]
name=Unixmen Repository
baseurl=http://18.234.132.162
gpgcheck=0
enabled=1
EOF
- name: Clean the repo
command: yum clean all