Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/galaxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

name: Deploy on Ansible Galaxy

'on':
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: galaxy
uses: robertdebock/galaxy-action@1.2.0
with:
galaxy_api_key: ${{ secrets.galaxy_api_key }}
35 changes: 35 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Molecule

'on':
pull_request:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scenario:
- debian-10
- debian-11
- debian-12
- ubuntu-18.04
- ubuntu-20.04
- ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"

- name: Molecule
uses: gofrolist/molecule-action@v2.3.19
with:
molecule_options: --base-config molecule/_shared/base.yml
molecule_args: --scenario-name ${{ matrix.scenario }}
molecule_working_dir: "HanXHX/ansible-debian-bootstrap"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.swp
*.retry
/ubuntu*.log
/.idea
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Ansible Debian/Devuan/Ubuntu/Raspbian bootstrap
====================================================

[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.debian_bootstrap-blue.svg)](https://galaxy.ansible.com/HanXHX/debian_bootstrap) [![Build Status](https://app.travis-ci.com/HanXHX/ansible-debian-bootstrap.svg?branch=master)](https://app.travis-ci.com/HanXHX/ansible-debian-bootstrap)
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.debian_bootstrap-blue.svg)](https://galaxy.ansible.com/HanXHX/debian_bootstrap) ![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/hanxhx/ansible-debian-bootstrap/molecule.yml?branch=master)

This role bootstraps Debian/Devuan/Ubuntu/Raspbian hosts:

Expand Down Expand Up @@ -152,6 +152,34 @@ Due to Docker limitations, theses features are disabled:
- Setting hostname
- Configure sysctl


How to develop and test this role
---------------------------------

### Vagrant way

Install vagrant + virtualbox or docker

```commandline
vagrant up debian-bullseye # with virtualbox
vagrant up docker-debian-bullseye # with docker
```

### Molecule way

Install:

```commandline
pip install molecule molecule[docker]
```

Run:

```commandline
molecule -vv -c molecule/_shared/base.yml converge -s ubuntu-22.04
```


License
-------

Expand Down
19 changes: 19 additions & 0 deletions molecule/_shared/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

{% if item.env is defined %}
{% for var, value in item.env.items() %}
{% if value %}
ENV {{ var }} {{ value }}
{% endif %}
{% endfor %}
{% endif %}

RUN apt-get update && \
apt-get install -y python3 sudo bash ca-certificates iproute2 python-apt-common \
&& apt-get clean
37 changes: 37 additions & 0 deletions molecule/_shared/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

scenario:
test_sequence:
- dependency
- syntax
- create
- prepare
- converge
- idempotence
- verify
- destroy
dependency:
name: galaxy
options:
requirements-file: ../../requirements.yml
driver:
name: docker
role_name_check: 1
provisioner:
name: ansible
config_options:
defaults:
deprecation_warnings: false
callback_whitelist: timer,profile_tasks
fact_caching: jsonfile
fact_caching_connection: ./cache
forks: 100
connection:
pipelining: true
playbooks:
converge: ../_shared/converge.yml

# TODO: Add this back in when we have a testinfra verifier
# verifier:
# name: testinfra
# directory: ../_shared/tests
12 changes: 12 additions & 0 deletions molecule/_shared/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Converge
hosts: all
gather_facts: true
tasks:
- name: Include role
ansible.builtin.include_role:
name: "hanxhx.debian_bootstrap"
vars:
# Force SysVinit, since systemd won't work in a Docker container
ansible_service_mgr: "sysvinit"
13 changes: 13 additions & 0 deletions molecule/debian-10/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: debian-10
image: dokken/debian-10
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
13 changes: 13 additions & 0 deletions molecule/debian-11/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: debian-11
image: dokken/debian-11
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
13 changes: 13 additions & 0 deletions molecule/debian-12/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: debian-12
image: dokken/debian-12
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
Empty file added molecule/default/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions molecule/ubuntu-18.04/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: ubuntu-18.04
image: dokken/ubuntu-18.04
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
13 changes: 13 additions & 0 deletions molecule/ubuntu-20.04/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: ubuntu-20.04
image: dokken/ubuntu-20.04
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
13 changes: 13 additions & 0 deletions molecule/ubuntu-22.04/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

platforms:
- name: ubuntu-22.04
image: dokken/ubuntu-22.04
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
1 change: 1 addition & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

collections:
- community.general
- ansible.posix