Skip to content

Commit 484cdd0

Browse files
Different CI, same role.
1 parent d77a218 commit 484cdd0

File tree

5 files changed

+61
-117
lines changed

5 files changed

+61
-117
lines changed

.github/workflows/molecule.yml

Lines changed: 40 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ on:
1515

1616
jobs:
1717
lint:
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-latest
1919
steps:
2020
- name: checkout
2121
uses: actions/checkout@v4
2222
- name: ansible-lint
2323
uses: ansible-community/ansible-lint-action@main
2424

25-
python-3-9:
25+
molecule:
2626
needs:
2727
- lint
28-
runs-on: ubuntu-20.04
29-
container:
30-
image: python:3.9
28+
runs-on: ubuntu-latest
3129
strategy:
3230
fail-fast: false
3331
matrix:
34-
config:
32+
distro:
3533
- image: "alpine"
3634
tag: "latest"
3735
- image: "amazonlinux"
@@ -57,104 +55,46 @@ jobs:
5755
steps:
5856
- name: checkout
5957
uses: actions/checkout@v4
58+
with:
59+
path: ansible-role-bootstrap
6060

61-
- name: molecule
61+
- name: Set up Python
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: "3.13"
65+
66+
- name: Configure Docker for systemd
6267
run: |
63-
apt-get update -qq
64-
apt-get -y -qq install yamllint docker.io
65-
pip install --no-cache-dir tox
66-
if [ -f tox.ini ] ; then tox ; fi
67-
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
68-
env:
69-
image: ${{ matrix.config.image }}
70-
tag: ${{ matrix.config.tag }}
71-
python-3-10:
72-
needs:
73-
- lint
74-
runs-on: ubuntu-20.04
75-
container:
76-
image: python:3.10
77-
strategy:
78-
fail-fast: false
79-
matrix:
80-
config:
81-
- image: "alpine"
82-
tag: "latest"
83-
- image: "amazonlinux"
84-
tag: "latest"
85-
- image: "enterpriselinux"
86-
tag: "latest"
87-
- image: "debian"
88-
tag: "latest"
89-
- image: "debian"
90-
tag: "bullseye"
91-
- image: "fedora"
92-
tag: "40"
93-
- image: "fedora"
94-
tag: "latest"
95-
- image: "fedora"
96-
tag: "rawhide"
97-
- image: "ubuntu"
98-
tag: "latest"
99-
- image: "ubuntu"
100-
tag: "jammy"
101-
- image: "ubuntu"
102-
tag: "focal"
103-
steps:
104-
- name: checkout
105-
uses: actions/checkout@v4
68+
sudo mkdir -p /etc/docker
69+
echo '{
70+
"features": {
71+
"buildkit": true
72+
},
73+
"exec-opts": ["native.cgroupdriver=systemd"]
74+
}' | sudo tee /etc/docker/daemon.json
75+
sudo systemctl restart docker || true
10676
107-
- name: molecule
77+
- name: Install Docker
78+
uses: docker/setup-buildx-action@v3
79+
80+
- name: Install dependencies
10881
run: |
109-
apt-get update -qq
110-
apt-get -y -qq install yamllint docker.io
111-
pip install --no-cache-dir tox
112-
if [ -f tox.ini ] ; then tox ; fi
113-
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
114-
env:
115-
image: ${{ matrix.config.image }}
116-
tag: ${{ matrix.config.tag }}
117-
python-3-13:
118-
needs:
119-
- lint
120-
runs-on: ubuntu-20.04
121-
container:
122-
image: python:3.13
123-
strategy:
124-
fail-fast: false
125-
matrix:
126-
config:
127-
- image: "alpine"
128-
tag: "latest"
129-
- image: "enterpriselinux"
130-
tag: "latest"
131-
- image: "debian"
132-
tag: "latest"
133-
- image: "debian"
134-
tag: "bullseye"
135-
- image: "fedora"
136-
tag: "40"
137-
- image: "fedora"
138-
tag: "latest"
139-
- image: "fedora"
140-
tag: "rawhide"
141-
- image: "ubuntu"
142-
tag: "latest"
143-
- image: "ubuntu"
144-
tag: "jammy"
145-
- image: "ubuntu"
146-
tag: "focal"
147-
steps:
148-
- name: checkout
149-
uses: actions/checkout@v4
82+
python -m pip install --upgrade pip
83+
pip install ansible-lint molecule molecule-plugins[docker] ansible-core
84+
if [ -f ansible-role-bootstrap/requirements.txt ]; then pip install -r ansible-role-bootstrap/requirements.txt; fi
85+
if [ -f ansible-role-bootstrap/requirements.yml ]; then ansible-galaxy install -r ansible-role-bootstrap/requirements.yml; fi
86+
87+
# Create proper role directory structure for molecule
88+
mkdir -p ~/.ansible/roles
89+
ln -s ${GITHUB_WORKSPACE}/ansible-role-bootstrap ~/.ansible/roles/robertdebock.bootstrap
15090
151-
- name: molecule
91+
- name: Test with molecule
15292
run: |
153-
apt-get update -qq
154-
apt-get -y -qq install yamllint docker.io
155-
pip install --no-cache-dir tox
156-
if [ -f tox.ini ] ; then tox ; fi
157-
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
93+
cd ansible-role-bootstrap
94+
molecule test
15895
env:
159-
image: ${{ matrix.config.image }}
160-
tag: ${{ matrix.config.tag }}
96+
PY_COLORS: 1
97+
ANSIBLE_FORCE_COLOR: 1
98+
ANSIBLE_ROLES_PATH: ~/.ansible/roles:${GITHUB_WORKSPACE}/ansible-role-bootstrap
99+
image: ${{ matrix.distro.image }}
100+
tag: ${{ matrix.distro.tag }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.tox
55
.cache
66
.DS_Store
7+
.ansible

.gitlab-ci.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,56 @@ variables:
44
DEBIAN_FRONTEND: noninteractive
55

66
molecule:
7-
image: $python
7+
image: python:3.13
88
script:
99
- apt-get update -qq
1010
- apt-get -y -qq install yamllint docker.io
11-
- pip install --no-cache-dir tox
12-
- if [ -f tox.ini ] ; then tox ; fi
13-
- if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
11+
# Configure Docker for systemd
12+
- mkdir -p /etc/docker
13+
- echo '{"features":{"buildkit":true},"exec-opts":["native.cgroupdriver=systemd"]}' > /etc/docker/daemon.json
14+
- service docker restart || true
15+
# Install dependencies and run tests
16+
- pip install --no-cache-dir ansible-lint molecule molecule-plugins[docker] ansible-core
17+
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
18+
- if [ -f requirements.yml ]; then ansible-galaxy install -r requirements.yml; fi
19+
# Create proper role directory structure for molecule
20+
- mkdir -p ~/.ansible/roles
21+
- ln -s $CI_PROJECT_DIR ~/.ansible/roles/robertdebock.bootstrap
22+
# Run molecule tests
23+
- cd $CI_PROJECT_DIR
24+
- ANSIBLE_ROLES_PATH=~/.ansible/roles:$CI_PROJECT_DIR molecule test
1425
rules:
1526
- if: $CI_COMMIT_REF_NAME == "master"
1627
parallel:
1728
matrix:
1829
- image: "alpine"
1930
tag: "latest"
20-
python: ['python:3.9', 'python:3.10', 'python:3.13']
2131
- image: "amazonlinux"
2232
tag: "latest"
23-
python: ['python:3.9', 'python:3.10']
2433
- image: "enterpriselinux"
2534
tag: "latest"
26-
python: ['python:3.9', 'python:3.10', 'python:3.13']
2735
- image: "debian"
2836
tag: "latest"
29-
python: ['python:3.9', 'python:3.10', 'python:3.13']
3037
- image: "debian"
3138
tag: "bullseye"
32-
python: ['python:3.9', 'python:3.10', 'python:3.13']
3339
- image: "fedora"
3440
tag: "40"
35-
python: ['python:3.9', 'python:3.10', 'python:3.13']
3641
- image: "fedora"
3742
tag: "latest"
38-
python: ['python:3.9', 'python:3.10', 'python:3.13']
3943
- image: "fedora"
4044
tag: "rawhide"
41-
python: ['python:3.9', 'python:3.10', 'python:3.13']
4245
- image: "ubuntu"
4346
tag: "latest"
44-
python: ['python:3.9', 'python:3.10', 'python:3.13']
4547
- image: "ubuntu"
4648
tag: "jammy"
47-
python: ['python:3.9', 'python:3.10', 'python:3.13']
4849
- image: "ubuntu"
4950
tag: "focal"
50-
python: ['python:3.9', 'python:3.10', 'python:3.13']
5151

5252
galaxy:
53+
image: python:3.13
5354
script:
54-
- apk add ansible-core
55+
- apt-get update -qq
56+
- apt-get -y -qq install ansible-core
5557
- ansible-galaxy role import --api-key ${GALAXY_API_KEY} robertdebock ${CI_PROJECT_NAME}
5658
rules:
5759
- if: $CI_COMMIT_TAG != null

molecule/default/converge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
gather_facts: false
1313

1414
roles:
15-
- role: ansible-role-bootstrap
15+
- role: robertdebock.bootstrap

molecule/default/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ platforms:
1717
- name: "bootstrap-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}"
1818
image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}"
1919
command: /sbin/init
20+
cgroupns_mode: host
2021
volumes:
2122
- /sys/fs/cgroup:/sys/fs/cgroup:rw
2223
privileged: true

0 commit comments

Comments
 (0)