mirror of
https://github.com/Dannecron/netology-devops-ansible-vector.git
synced 2025-12-25 22:42:34 +03:00
add molecule testing against centos:7
This commit is contained in:
33
.yamllint
Normal file
33
.yamllint
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# Based on ansible-lint config
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
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
|
||||||
|
comments: disable
|
||||||
|
comments-indentation: disable
|
||||||
|
document-start: disable
|
||||||
|
empty-lines:
|
||||||
|
max: 3
|
||||||
|
level: error
|
||||||
|
hyphens:
|
||||||
|
level: error
|
||||||
|
indentation: disable
|
||||||
|
key-duplicates: enable
|
||||||
|
line-length: disable
|
||||||
|
new-line-at-end-of-file: disable
|
||||||
|
new-lines:
|
||||||
|
type: unix
|
||||||
|
trailing-spaces: disable
|
||||||
|
truthy: disable
|
||||||
42
molecule/default/Dockerfile.j2
Normal file
42
molecule/default/Dockerfile.j2
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{% 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 if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y apt-transport-https gnupg2 python3-minimal python3-apt man systemd systemd-sysv rsyslog sudo bash ca-certificates iproute2 && apt-get clean; \
|
||||||
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes upgrade && dnf --assumeyes install python3 sudo python3-devel python*-dnf bash iproute && dnf clean all; \
|
||||||
|
elif [ $(command -v yum) ]; then sed -i 's/^\(tsflags=*\)/# \1/g' /etc/yum.conf && yum makecache fast && yum upgrade -y && yum makecache fast && yum install -y sudo python3 systemd rsyslog man yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||||
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \
|
||||||
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
||||||
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi
|
||||||
|
|
||||||
|
RUN set -xe \
|
||||||
|
&& groupadd -r ${ANSIBLE_USER} \
|
||||||
|
&& groupadd -r ${DEPLOY_GROUP} \
|
||||||
|
&& useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \
|
||||||
|
&& usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \
|
||||||
|
&& echo "%${DEPLOY_GROUP} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible
|
||||||
|
|
||||||
|
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
|
||||||
|
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||||
|
rm -rf /lib/systemd/system/multi-user.target.wants/*;\
|
||||||
|
rm -rf /etc/systemd/system/*.wants/*;\
|
||||||
|
rm -rf /lib/systemd/system/local-fs.target.wants/*; \
|
||||||
|
rm -rf /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||||
|
rm -rf /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||||
|
rm -rf /lib/systemd/system/basic.target.wants/*;\
|
||||||
|
rm -rf /lib/systemd/system/anaconda.target.wants/*;
|
||||||
|
|
||||||
|
VOLUME [ "/sys/fs/cgroup" ]
|
||||||
|
CMD ["{{ item.command | default('/usr/sbin/init') }}"]
|
||||||
7
molecule/default/converge.yml
Normal file
7
molecule/default/converge.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: "Include netology_devops_vector"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "dannc.netology_devops_vector"
|
||||||
45
molecule/default/molecule.yml
Normal file
45
molecule/default/molecule.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
lint: |
|
||||||
|
yamllint .
|
||||||
|
ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: centos_7
|
||||||
|
image: centos:7
|
||||||
|
privileged: true
|
||||||
|
command: /usr/sbin/init
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /tmp
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup
|
||||||
|
env:
|
||||||
|
ANSIBLE_USER: ansible
|
||||||
|
SUDO_GROUP: wheel
|
||||||
|
DEPLOY_GROUP: deployer
|
||||||
|
container: docker
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
name: default
|
||||||
|
test_sequence:
|
||||||
|
- lint
|
||||||
|
- destroy
|
||||||
|
# - dependency
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
# - prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
# - side_effect
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
8
molecule/default/verify.yml
Normal file
8
molecule/default/verify.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Example assertion
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: true
|
||||||
Reference in New Issue
Block a user