/
main.yml
109 lines (96 loc) · 2.92 KB
/
main.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
- become: true
block:
- name: Install required packages
package:
name: 'epel-release'
state: present
- name: Install new dlrn repos
get_url:
url: "{{ item }}"
dest: "/etc/yum.repos.d/{{ item.split('/')[-1] }}"
with_items:
- https://trunk.rdoproject.org/centos8-master/current-tripleo/delorean.repo
- https://trunk.rdoproject.org/centos8/delorean-deps.repo
- name: Install required packages
dnf:
name: '{{ packages }}'
state: present
- name: Create {{ web_directory }}
file:
path: "{{ web_directory }}"
state: directory
mode: u+rwX,g+rX,o+rX
- name: Check if no server runs
command: podman ps -aq -f name=nginx
register: container_ps
changed_when: false
- name: Create config
template:
src: nginx-default.conf.j2
dest: ~/nginx-default.conf
- name: Start web server
command: >-
podman run -d
-p 80:80
-v ~/nginx-default.conf:/etc/nginx/conf.d/default.conf:ro,z
-v {{ web_directory }}:/usr/share/nginx/html:ro,z
--name nginx
--log-driver=journald
nginx
when: not container_ps.stdout
changed_when: true
- name: Create repo directory
file:
path: /opt/stack/
state: directory
- name: Clone repos
git:
repo: '{{ item.repo }}'
dest: '{{ item.path }}'
version: master
force: yes
with_items:
- repo: https://github.com/rdo-infra/ci-config.git
path: /opt/stack/ci-config
- name: Create logrotate for cron jobs
copy:
dest: /etc/logrotate.d/cron_clean_logs
content: |
/var/log/clean_* {
daily
missingok
dateext
dateyesterday
notifempty
delaycompress
rotate 20
nomail
create 0600 root root
}
- name: Create cron job to cleanup keypairs
cron:
name: 'Cleaning keypairs'
minute: 50
job: >-
source /etc/vexxhostrc-ovb &&
bash /opt/stack/ci-config/ci-scripts/infra-cleanup/cleanup-keys.sh
&>> "{{ web_directory }}/clean_keypairs.log.txt"
- name: Create cron job to clean OVB old and failed stacks on different clouds
cron:
minute: 30
name: "Cleaning old OVB stacks on {{ item.name }} Cloud"
job: >-
python3 /opt/stack/ci-config/ci-scripts/infra-cleanup/tenant_cleanup/ovb_tenant_cleanup.py
-c "{{ item.job }}" -l "{{ web_directory }}/clean_stacks_{{ item.job }}.log.txt"
with_items:
- { job: 'vexx_cloud', name: "Vexxhost" }
- { job: 'ibm-bm2-nodepool', name: "IBM" }
- name: Create cron job to get influxdb stats on vexxhost
cron:
name: 'Get influxdb stats vexx'
minute: '*/15'
job: >-
python3 /opt/stack/ci-config/ci-scripts/infra-setup/roles/rrcockpit/files/telegraf_py3/vexxhost.py
--webdir {{ web_directory }}
&>/var/log/influxdb_stats_vexx.log