Skip to content

Commit 973c9d3

Browse files
committed
single playbook
Signed-off-by: Antonio Murdaca <[email protected]>
1 parent 2719516 commit 973c9d3

File tree

5 files changed

+90
-163
lines changed

5 files changed

+90
-163
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
This playbook provisions a CentOS 7.3/Ubuntu 16.04 machine with everything you need in order to
1+
This playbook provisions a CentOS 7.3/Ubuntu 16.04/RHEL/Fedora 25+ machine with everything you need in order to
22
use `kubeadm` and `CRI-O` (no `docker` no more). Simply run:
33

4+
Create an ansible `hosts` file (adjust anything needed like `ansible_python_interpreter`):
45
```sh
5-
./run.sh centos <IP or hostname>
6-
# if you're on Ubuntu
7-
./run.sh ubuntu <IP or hostname>
6+
$ cat hosts
7+
192.168.1.122 ansible_python_interpreter='python3'
8+
```
9+
10+
Then simply run:
11+
12+
```sh
13+
$ ansible-playbook -i hosts cri-o.yml
814
```
915

1016
**make sure the machine is reachable via SSH w/o password input**

centos.yml renamed to cri-o.yml

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,32 @@
22
- hosts: all
33
remote_user: root
44
tasks:
5-
- name: Make sure we have all required packages
5+
- name: Make sure we have all required packages on Fedora
6+
dnf:
7+
name: "{{ item }}"
8+
state: latest
9+
with_items:
10+
- wget
11+
- git
12+
- make
13+
- gcc
14+
- tar
15+
- libseccomp-devel
16+
- golang
17+
- glib2-devel
18+
- glibc-static
19+
- container-selinux
20+
- btrfs-progs-devel
21+
- device-mapper-devel
22+
- glibc-devel
23+
- gpgme-devel
24+
- libassuan-devel
25+
- libgpg-error-devel
26+
- pkgconfig
27+
- skopeo-containers
28+
when: ansible_distribution == 'Fedora'
29+
- name: Make sure we have all required packages on RHEL/CentOS
30+
when: (ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS')
631
yum:
732
name: "{{ item }}"
833
state: latest
@@ -27,6 +52,33 @@
2752
- json-glib-devel
2853
- skopeo-containers
2954
- docker
55+
- name: Make sure we have all required packages on Ubuntu
56+
package:
57+
name: "{{ item }}"
58+
state: latest
59+
with_items:
60+
- apt-transport-https
61+
- build-essential
62+
- curl
63+
- gawk
64+
- iptables
65+
- pkg-config
66+
- libaio-dev
67+
- libcap-dev
68+
- libprotobuf-dev
69+
- libseccomp2
70+
- libseccomp-dev
71+
- protobuf-compiler
72+
- python-minimal
73+
- libglib2.0-dev
74+
- libjson-glib-dev
75+
- libapparmor-dev
76+
- btrfs-tools
77+
- libdevmapper1.02.1
78+
- libdevmapper-dev
79+
- libgpgme11-dev
80+
- aptitude
81+
when: ansible_distribution == 'Ubuntu'
3082
- name: Make directories
3183
file:
3284
path: "{{ item }}"
@@ -36,19 +88,36 @@
3688
- /etc/systemd/system/kubelet.service.d/
3789
- /var/lib/etcd
3890
- /etc/cni/net.d
39-
- name: install Golang upstream in CentOS
91+
- /etc/containers
92+
- name: install Golang upstream
4093
shell: |
4194
curl -fsSL "https://golang.org/dl/go1.8.3.linux-amd64.tar.gz" \
4295
| tar -xzC /usr/local
43-
- name: Set custom Golang path for CentOS
96+
- name: Set custom Golang path in RHEL/CentOS/Fedora
4497
lineinfile:
4598
dest: /root/.bashrc
4699
line: 'export PATH=/usr/local/go/bin:$PATH'
47100
insertafter: 'EOF'
48101
regexp: 'export PATH=\/usr\/local\/go\/bin:\$PATH'
49102
state: present
50-
- name: update all
103+
when: (ansible_distribution == 'Fedora' or ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS')
104+
- name: link golang in Ubuntu
105+
file: src=/usr/local/go/bin/go dest=/usr/bin/go state=link
106+
when: ansible_distribution == 'Ubuntu'
107+
- name: Update all in Ubuntu
108+
apt:
109+
upgrade: yes
110+
update_cache: yes
111+
cache_valid_time: 86400 #One day
112+
when: ansible_distribution == 'Ubuntu'
113+
- name: update all in RHEL/CentOS
51114
yum: name=* state=latest
115+
when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS'
116+
- name: Update all packages on Fedora
117+
dnf:
118+
name: '*'
119+
state: latest
120+
when: ansible_distribution == 'Fedora'
52121
- name: clone runc
53122
git:
54123
repo: https://github.com/opencontainers/runc
@@ -83,6 +152,10 @@
83152
make install.systemd && \
84153
make install.config
85154
when: clone_crio.changed
155+
- name: install policy.json in Ubuntu
156+
shell: |
157+
cd /root/src/github.com/kubernetes-incubator/cri-o && \
158+
cp test/policy.json /etc/containers/policy.json
86159
- name: build CNI stuff
87160
shell: |
88161
cd /root/src/github.com/containernetworking/plugins && \
@@ -96,6 +169,7 @@
96169
replace: 'systemd'
97170
name: /etc/crio/crio.conf
98171
backup: yes
172+
when: (ansible_distribution == 'Fedora' or ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS')
99173
- name: run with overlay2
100174
replace:
101175
regexp: 'storage_driver = ""'
@@ -109,6 +183,7 @@
109183
insertafter: 'storage_option = \['
110184
regexp: 'overlay2\.override_kernel_check=1'
111185
state: present
186+
when: (ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS')
112187
- name: enable and start CRI-O
113188
systemd:
114189
name: crio
@@ -140,3 +215,4 @@
140215
dest: /etc/selinux/config
141216
line: 'SELINUX=permissive'
142217
regexp: '^SELINUX='
218+
when: (ansible_distribution == 'Fedora' or ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS')

hosts.template

Lines changed: 0 additions & 1 deletion
This file was deleted.

run.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

ubuntu.yml

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)