Skip to content

Commit 2d74e0d

Browse files
committed
chore(Ansible): Basic ansible role sceleton with molecule enabled
1 parent 3bdadbf commit 2d74e0d

23 files changed

Lines changed: 292 additions & 1 deletion

.ansible-lint

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parseable: true
2+
quiet: false
3+
use_default_rules: true
4+
skip_list:
5+
- ANSIBLE0006
6+
- ANSIBLE0012
7+
- ANSIBLE0013
8+
- 306
9+
verbosity: 1
10+
exclude_paths:
11+
- roles

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# Howto with your editor:
4+
# Sublime: https://github.com/sindresorhus/editorconfig-sublime
5+
6+
# top-most EditorConfig file
7+
root = true
8+
9+
# Unix-style newlines with a newline ending every file
10+
[**]
11+
end_of_line = lf
12+
insert_final_newline = true
13+
indent_style = space
14+
15+
# Standard at: https://github.com/felixge/node-style-guide
16+
[**.js, **.json]
17+
trim_trailing_whitespace = true
18+
indent_style = space
19+
indent_size = 2
20+
quote_type = single
21+
curly_bracket_next_line = false
22+
spaces_around_operators = true
23+
space_after_control_statements = true
24+
space_after_anonymous_functions = false
25+
spaces_in_brackets = false
26+
27+
# No Standard. Please document a standard if different from .js
28+
[**.yml, **.html, **.css]
29+
trim_trailing_whitespace = true
30+
indent_style = space
31+
indent_size = 2
32+
33+
# No standard. Please document a standard if different from .js
34+
[**.md]
35+
indent_style = space

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
# do not add excludes for files in repo
3+
exclude = .venv/,.tox/,dist/,build/,.eggs/
4+
format = pylint
5+
ignore = E302,E501

.yamllint

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
extends: default
3+
rules:
4+
line-length:
5+
max: 150
6+
level: warning
7+
braces:
8+
max-spaces-inside: 1
9+
level: error
10+
brackets:
11+
max-spaces-inside: 1
12+
level: error
13+
line-length: disable
14+
ignore: |
15+
*.yaml
16+
deploy.yml
17+
test.yml
18+
update.yml
19+
*.sh
20+
*.py
21+
*/*.sh
22+
roles/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# ansible-secure-docker
1+
# Ansible Role to secure docker installation
2+
3+
> Main purpose is to prevent docker containers to expose ports via iptables port-forward to non-local interfaces

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

handlers/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- name: docker_restart
4+
service:
5+
name: docker
6+
state: restarted

meta/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
galaxy_info:
3+
author: Martin Reinhardt, <contact@martinreinhardt-online.de>
4+
description: Role securing docker
5+
6+
license: MIT
7+
8+
min_ansible_version: 2.7.1
9+
10+
11+
platforms:
12+
- name: Debian
13+
versions:
14+
- jessie
15+
- stretch
16+
17+
galaxy_tags:
18+
- docker
19+
20+
dependencies: []

molecule/default/Dockerfile.j2

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Molecule managed
2+
3+
{% if item.registry is defined %}
4+
FROM {{ item.registry.url }}/{{ item.image }}
5+
{% else %}
6+
FROM {{ item.image }}
7+
{% endif %}
8+
9+
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates cron gpg nginx systemd systemd-sysv vim && apt-get clean; \
10+
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
11+
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; \
12+
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
13+
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
14+
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
15+
16+
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
17+
/etc/systemd/system/*.wants/* \
18+
/lib/systemd/system/local-fs.target.wants/* \
19+
/lib/systemd/system/sockets.target.wants/*udev* \
20+
/lib/systemd/system/sockets.target.wants/*initctl* \
21+
/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \
22+
/lib/systemd/system/systemd-update-utmp*
23+
24+
VOLUME [ "/sys/fs/cgroup" ]
25+
26+
CMD ["/lib/systemd/systemd"]

molecule/default/INSTALL.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*******
2+
Docker driver installation guide
3+
*******
4+
5+
Requirements
6+
============
7+
8+
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
9+
* Docker Engine
10+
* docker-py
11+
* docker
12+
13+
Install
14+
=======
15+
16+
$ sudo pip install docker-py

0 commit comments

Comments
 (0)