-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7cfbf7d
Showing
19 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
exclude_paths: | ||
- ./molecule | ||
- ./.github | ||
parseable: true | ||
skip_list: | ||
- '204' | ||
- '208' | ||
use_default_rules: true | ||
verbosity: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.yml linguist-detectable=true | ||
*.yaml linguist-detectable=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
name: CI | ||
'on': | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: 'blalop.docker_arm' | ||
|
||
jobs: | ||
molecule: | ||
name: Molecule | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- distro: debian11 | ||
- distro: debian10 | ||
|
||
steps: | ||
- name: Check out the codebase | ||
uses: actions/checkout@v2 | ||
with: | ||
path: 'blalop.docker_arm' | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install test dependencies | ||
run: pip3 install ansible molecule[docker] docker yamllint ansible-lint | ||
|
||
- name: Run Molecule tests. | ||
run: molecule test | ||
env: | ||
PY_COLORS: '1' | ||
ANSIBLE_FORCE_COLOR: '1' | ||
MOLECULE_DISTRO: ${{ matrix.distro }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
# This workflow requires a GALAXY_API_KEY secret present in the GitHub | ||
# repository or organization. | ||
# | ||
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy | ||
# See: https://github.com/ansible/galaxy/issues/46 | ||
|
||
name: Release | ||
'on': | ||
push: | ||
tags: | ||
- '*' | ||
|
||
defaults: | ||
run: | ||
working-directory: 'blalop.docker_arm' | ||
|
||
jobs: | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the codebase | ||
uses: actions/checkout@v2 | ||
with: | ||
path: 'blalop.docker_arm' | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Ansible | ||
run: pip3 install ansible-base | ||
|
||
- name: Trigger a new import on Galaxy | ||
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__pycache__ | ||
*.pyc | ||
|
||
.pytest_cache | ||
.molecule | ||
.cache | ||
|
||
*.iml | ||
.idea | ||
.project | ||
|
||
**/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
# Based on ansible-lint config | ||
extends: default | ||
|
||
ignore: | | ||
molecule/**/tests/ | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
key-duplicates: enable | ||
line-length: disable | ||
new-lines: | ||
type: unix | ||
truthy: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog). | ||
|
||
## [Unreleased](https://github.com/blalop/ansible-role-docker_arm/tree/main) | ||
|
||
## [0.1.0](https://github.com/blalop/ansible-role-docker_arm/tree/0.1.0) - 2021-09-27 | ||
### Added | ||
* Initial release @blalop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 Alejandro Blanco | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Ansible role: Docker for ARM | ||
|
||
[![CI](https://github.com/blalop/ansible-role-docker_arm/workflows/CI/badge.svg?event=push)](https://github.com/blalop/ansible-role-docker_arm/actions?query=workflow%3ACI) | ||
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-blalop.docker_arm-B62682.svg)](https://galaxy.ansible.com/blalop/docker_arm) | ||
|
||
|
||
A heavily opinionated role to install Docker using the convenience script and docker-compose using pip. This role is intended to be used in ARM-based devices like Raspberry Pi although still being runnable on x64 hosts. | ||
|
||
## Requirements | ||
|
||
No special requirements. Use it in your playbook like this: | ||
|
||
``` | ||
- hosts: all | ||
roles: | ||
- blalop.docker_arm | ||
``` | ||
|
||
## Testing | ||
|
||
Test the role via molecule: | ||
|
||
``` | ||
pip install molecule | ||
molecule test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
docker_install_compose: true | ||
|
||
docker_daemon_options: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
- name: Restart docker | ||
systemd: | ||
name: docker | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
galaxy_info: | ||
role_name: docker_arm | ||
author: blalop | ||
description: Docker Role for ARM | ||
min_ansible_version: 2.8.0 | ||
license: MIT | ||
galaxy-tags: | ||
- system | ||
- networking | ||
- web | ||
- raspberry | ||
- docker | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- buster | ||
- bullseye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
vars: | ||
docker_daemon_options: | ||
storage-driver: "vfs" | ||
roles: | ||
- role: blalop.docker_arm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
|
||
driver: | ||
name: docker | ||
|
||
lint: | | ||
yamllint . | ||
ansible-lint . | ||
platforms: | ||
- name: docker_arm | ||
groups: | ||
- docker_arm_group | ||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-debian11}-ansible:latest" | ||
pre_build_image: true | ||
privileged: true | ||
volumes: | ||
- '/sys/fs/cgroup:/sys/fs/cgroup:ro' | ||
command: '/lib/systemd/systemd' | ||
stop_signal: 'RTMIN+3' | ||
dns_servers: | ||
- 8.8.8.8 | ||
|
||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
service: | ||
docker: | ||
enabled: true | ||
running: true | ||
|
||
command: | ||
hello-world: | ||
exec: "docker run hello-world" | ||
exit-status: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
|
||
- name: Verify docker_arm | ||
hosts: | ||
- docker_arm | ||
become: true | ||
vars: | ||
goss_version: v0.3.16 | ||
goss_arch: amd64 | ||
goss_dst: /usr/local/bin/goss | ||
goss_sha256sum: 827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb | ||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}" | ||
goss_test_directory: /tmp | ||
goss_format: documentation | ||
|
||
vars_files: | ||
- ../../defaults/main.yml | ||
|
||
tasks: | ||
- name: Download and install Goss | ||
get_url: | ||
url: "{{ goss_url }}" | ||
dest: "{{ goss_dst }}" | ||
sha256sum: "{{ goss_sha256sum }}" | ||
mode: 0755 | ||
register: download_goss | ||
until: download_goss is succeeded | ||
retries: 3 | ||
|
||
- name: Copy Goss tests to remote | ||
copy: | ||
src: tests/test_docker.yml | ||
dest: "{{ goss_test_directory }}/test_docker.yml" | ||
|
||
- name: Register test files | ||
shell: "ls {{ goss_test_directory }}/test_*.yml" | ||
register: test_files | ||
|
||
- name: Execute Goss tests | ||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}" | ||
register: test_results | ||
with_items: "{{ test_files.stdout_lines }}" | ||
|
||
- name: Display details about the Goss results | ||
debug: | ||
msg: "{{ item.stdout_lines }}" | ||
with_items: "{{ test_results.results }}" | ||
|
||
- name: Fail when tests fail | ||
fail: | ||
msg: "Goss failed to validate" | ||
when: item.rc != 0 | ||
with_items: "{{ test_results.results }}" |
Oops, something went wrong.