Skip to content

Commit 404d120

Browse files
author
Gustavo Muniz do Carmo
committed
add centos support
1 parent 6efaafe commit 404d120

9 files changed

Lines changed: 57 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/*/__pycache__
22
.vscode
3+
env

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ If the build is succeeded, dependent roles may have also its builds triggered, t
2323
2424
## Test yourself
2525
26-
Inside your [Python virtual environment](https://docs.python.org/3/tutorial/venv.html), run:
26+
First of all, create your [Python virtual environment](https://docs.python.org/3/tutorial/venv.html) and activate it:
2727
28-
`pip install -r requirements.txt`
28+
`python -m venv env && source env/bin/activate`
2929

30-
And then:
30+
After that, install all requirements:
31+
32+
`pip install wheel && pip install -r requirements.txt`
33+
34+
Finally, execute the test:
3135

3236
`molecule test`
3337

meta/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ galaxy_info:
1111
versions:
1212
- bionic
1313
- xenial
14+
- name: CentOS
15+
versions:
16+
- 7
17+
- 8
1418

1519
galaxy_tags:
1620
- docker

molecule/default/Dockerfile.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ FROM {{ item.registry.url }}/{{ item.image }}
66
FROM {{ item.image }}
77
{% endif %}
88

9-
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
10-
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
9+
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates python-apt aptitude && apt-get clean; \
10+
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python2 sudo python2-devel && dnf clean all; \
1111
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
1212
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
1313
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \

molecule/default/molecule.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ lint:
88
platforms:
99
- name: xenial
1010
image: ubuntu:xenial
11+
groups:
12+
- ubuntu
1113
- name: bionic
1214
image: ubuntu:bionic
15+
groups:
16+
- ubuntu
17+
- name: centos7
18+
image: centos:7
19+
groups:
20+
- centos
21+
- name: centos8
22+
image: centos:8
23+
groups:
24+
- centos
1325
provisioner:
1426
name: ansible
1527
lint:

molecule/default/tests/test_default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import testinfra.utils.ansible_runner
44

55
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
6-
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
6+
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('ubuntu')
77

88

99
def test_docker_is_installed(host):

tasks/centos.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Install required packages
3+
yum:
4+
name: "{{ item }}"
5+
loop:
6+
- yum-utils
7+
- device-mapper-persistent-data
8+
- lvm2

tasks/main.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
---
2-
- name: Install required packages
3-
apt:
4-
name: "{{ item }}"
5-
loop:
6-
- software-properties-common
7-
- apt-transport-https
8-
- name: Add the Docker apt key
9-
apt_key:
10-
url: https://download.docker.com/linux/ubuntu/gpg
11-
- name: Add the Docker apt repository
12-
apt_repository:
13-
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
14-
- name: Install Docker
15-
apt:
16-
name: docker-ce
17-
update_cache: yes
2+
- name: Execute the appropriate tasks, depending on the distribution.
3+
include: "{{ ansible_distribution | lower }}.yml"

tasks/ubuntu.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Install required packages
3+
apt:
4+
name: "{{ item }}"
5+
loop:
6+
- software-properties-common
7+
- apt-transport-https
8+
9+
- name: Add the Docker apt key
10+
apt_key:
11+
url: https://download.docker.com/linux/ubuntu/gpg
12+
13+
- name: Add the Docker apt repository
14+
apt_repository:
15+
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
16+
17+
- name: Install Docker
18+
apt:
19+
name: docker-ce
20+
update_cache: yes

0 commit comments

Comments
 (0)