Skip to content

Commit 262e02a

Browse files
author
Gustavo Muniz do Carmo
committed
add centos support
1 parent b08a2b9 commit 262e02a

File tree

9 files changed

+56
-50
lines changed

9 files changed

+56
-50
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ Ansible role to install [Ansible](https://www.ansible.com).
1313
- codeyourinfra.ansible
1414
```
1515
16-
The role requires the *ansible_python_version* variable, obtained through the [gathering facts phase](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#information-discovered-from-systems-facts). So please don't turn off facts.
16+
The role requires some variables obtained through the [gathering facts phase](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#information-discovered-from-systems-facts). So please don't turn off facts.
1717
1818
## Build process
1919
2020
The build process is performed in [Travis CI](https://travis-ci.org/codeyourinfra/ansible). During the build, the role is tested by using [Molecule](https://molecule.readthedocs.io).
2121
2222
## Test yourself
2323
24-
Inside your [Python virtual environment](https://docs.python.org/3/tutorial/venv.html), run:
24+
First of all, create your [Python virtual environment](https://docs.python.org/3/tutorial/venv.html) and activate it:
2525
26-
`pip install -r requirements.txt`
26+
`python -m venv env && source env/bin/activate`
2727

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

3034
`molecule test`
3135

meta/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ galaxy_info:
1111
versions:
1212
- bionic
1313
- xenial
14+
- name: CentOS
15+
versions:
16+
- 7
1417

1518
galaxy_tags:
1619
- ansible

molecule/default/Dockerfile.j2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ 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; \
1414
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
15+

molecule/default/molecule.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ 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
1321
provisioner:
1422
name: ansible
1523
lint:

tasks/centos.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Install EPEL
3+
yum:
4+
name: "{{ item }}"
5+
loop:
6+
- epel-release
7+
- ansible

tasks/main.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
1-
---
2-
- name: Install required packages
3-
apt:
4-
name: "{{ item }}"
5-
loop:
6-
- libssl-dev
7-
- libffi-dev
8-
9-
- name: Python version
10-
debug:
11-
var: ansible_python_version
12-
13-
- name: Install pip3/uninstall pip, if python3.
14-
apt:
15-
name: python3-pip
16-
state: "{{ 'present' if ansible_python_version is version('3', '>=') else 'absent' }}"
17-
18-
- name: Install pip/unsintall pip3, if python.
19-
apt:
20-
name: python-pip
21-
state: "{{ 'present' if ansible_python_version is version('3', '<') else 'absent' }}"
22-
23-
- name: Install Ansible
24-
pip:
25-
name: ansible
1+
- name: Execute the appropriate tasks, depending on the distribution.
2+
include: "{{ ansible_distribution | lower }}.yml"

tasks/ubuntu.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
- name: Install required packages
3+
apt:
4+
name: "{{ item }}"
5+
loop:
6+
- libssl-dev
7+
- libffi-dev
8+
9+
- name: Python version
10+
debug:
11+
var: ansible_python_version
12+
13+
- name: Install pip3/uninstall pip, if python3.
14+
apt:
15+
name: python3-pip
16+
state: "{{ 'present' if ansible_python_version is version('3', '>=') else 'absent' }}"
17+
18+
- name: Install pip/unsintall pip3, if python.
19+
apt:
20+
name: python-pip
21+
state: "{{ 'present' if ansible_python_version is version('3', '<') else 'absent' }}"
22+
23+
- name: Install Ansible
24+
pip:
25+
name: ansible

tests/inventory

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

tests/test.yml

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

0 commit comments

Comments
 (0)