blob: 0a30e0c57249b51eeac6827383a4bc684b6ea8c4 (
plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
---
- name: copy files
shell: |
docker exec compass-cobbler bash -c \
"cp -rf /root/cobbler/* /var/lib/cobbler/; \
rm -rf /var/lib/cobbler/conf; \
cp -rf /root/cobbler/conf/* /etc/cobbler"
- name: chmod migrate_ks.py
shell: |
docker exec compass-cobbler bash -c \
"chmod +x /var/lib/cobbler/triggers/sync/post/migrate_ks.py"
- name: render cobbler files
template:
src: "{{ item }}.j2"
dest: "{{ docker_compose_dir }}/cobbler/{{ item }}"
with_items:
- dhcp.template
- named.template
- settings
- zone.template
- name: copy files to /etc/cobbler
shell: |
docker cp "{{ docker_compose_dir }}/cobbler/{{ item }}" compass-cobbler:/etc/cobbler
with_items:
- dhcp.template
- named.template
- settings
- zone.template
# - name: restart cobblerd service
# shell: |
# docker exec compass-cobbler bash -c \
# "service cobblerd restart"
- name: prepare iso and ppa
shell: |
docker cp "{{ compass_dists_dir }}/{{ item.value.iso_name }}.iso" compass-cobbler:/tmp
docker exec compass-cobbler bash -c \
"mkdir -p /mnt/{{ item.value.iso_name }}; \
mount -o loop /tmp/{{ item.value.iso_name }}.iso /mnt/{{ item.value.iso_name }}"
docker cp "{{ compass_dists_dir }}/{{ item.value.ppa_name }}.tar.gz" compass-cobbler:/tmp
docker exec compass-cobbler bash -c \
"mkdir -p /var/lib/cobbler/repo_mirror/{{ item.value.ppa_name }}"
with_dict: "{{ vars['distros_' + ansible_architecture] }}"
run_once: "True"
ignore_errors: "True"
- name: cobbler import iso
shell: |
name="{{ item.value.cobbler_name }}"
docker exec compass-cobbler bash -c \
"service cobblerd restart;
sleep 3;
cobbler import --name $name \
--path /mnt/{{ item.value.iso_name }} \
--arch {{ item.value.cobbler_arch }} \
--kickstart /var/lib/cobbler/kickstarts/{{ item.value.kickstart }} \
--breed {{ item.value.breed }}"
with_dict: "{{ vars['distros_' + ansible_architecture] }}"
run_once: "True"
register: result2
until: result2.rc == 0
retries: 10
delay: 3
- name: add repos
shell: |
docker exec compass-cobbler bash -c \
"cobbler repo add --name {{ item.value.ppa_name }} \
--mirror /var/lib/cobbler/repo_mirror/{{ item.value.ppa_name }} \
--mirror-locally True \
--arch={{ item.value.cobbler_arch }} \
{{ item.value.extra | default() }}"
with_dict: "{{ vars['distros_' + ansible_architecture] }}"
run_once: "True"
- name: edit profiles for x86_64
shell: |
name="{{ item.value.cobbler_name }}-x86_64"
docker exec compass-cobbler bash -c \
"cobbler profile edit --name $name \
--name-servers '' \
--repos {{ item.value.ppa_name }} \
--ksmeta \"tree=http://{{ host_ip }}/cobbler/ks_mirror/$name\" \
--kopts \"{{ item.value.kopts | default('') }}\" \
--kopts-post \"{{ item.value.kopts_post | default('') }}\""
with_dict: "{{ distros_x86_64 }}"
run_once: "True"
when: ansible_architecture == "x86_64"
- name: edit profile for aarch64
shell: |
# Cobbler naming on Arm is a mess
# Imported name:
# - CentOS-7-Minimal-1611
# - ubuntu-16.04-server
# Profile name:
# - CentOS-7-Minimal-1611-arm-arm
# - ubuntu-16.04-server-arm-arm64-arm
# Kickstart meta url name
# - http://x.x.x.x/cobbler/ks_mirror/CentOS-7-Minimal-1611-arm
# - http://x.x.x.x/cobbler/ks_mirror/ubuntu-16.04-server-arm-arm64
name="{{ item.value.cobbler_name }}-arm"
profiles=`docker exec compass-cobbler bash -c \
"cobbler profile list | grep $name"`
for profile_name in $profiles; do
docker exec compass-cobbler bash -c \
"cobbler profile edit \
--name $profile_name \
--name-servers '' \
--repos {{ item.value.ppa_name }} \
--ksmeta \"tree=http://{{ host_ip }}/cobbler/ks_mirror/${profile_name%????}\" \
--kopts \"{{ item.value.kopts | default('') }}\" \
--kopts-post \"{{ item.value.kopts_post | default('') }}\""
done
with_dict: "{{ distros_aarch64 }}"
run_once: "True"
when: ansible_architecture == "aarch64"
- name: cobbler sync
shell: |
docker exec compass-cobbler bash -c \
"cobbler sync"
|