Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Add molecule tests
Browse files Browse the repository at this point in the history
Signed-off-by: Timur Gadiev <Timur_Gadiev@epam.com>
  • Loading branch information
tgadiev committed Nov 16, 2019
1 parent a1c2b39 commit 22a5738
Show file tree
Hide file tree
Showing 12 changed files with 451 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exclude_paths:
- ./.travis.yml
- ./molecule/
rulesdir:
- ~/ansible-lint-rules/rules/
use_default_rules: true
verbosity: 1
50 changes: 50 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# Run all tests
stages:
- lint
- deployment test

before_script:
- rm -rf molecule/resources/provisioning
- ansible --version
- ansible-lint --version
- molecule --version
- git clone https://github.com/lean-delivery/ansible-molecule-drivers.git molecule/resources/provisioning

variables:
GET_SOURCES_ATTEMPTS: "5"

Lint:
stage: lint
before_script:
- git clone https://github.com/lean-delivery/ansible-lint-rules.git ~/ansible-lint-rules
script:
- yamllint . -c .yamllint
- ansible-lint . -c .ansible-lint
after_script:
- rm -rf ~/ansible-lint-rules
tags:
- lint

.Docker ansible-beats:
stage: deployment test
script:
- molecule test -s default
tags:
- aws

AWS ansible-beats:
variables:
AWS_REGION: us-east-1
stage: deployment test
script:
- molecule test -s cloud-aws-direct
tags:
- aws

.AZURE ansible-beats:
stage: deployment test
script:
- molecule test -s cloud-azure-direct
tags:
- azure
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
dist: bionic
sudo: required

language: python
python:
- "3.7"

services:
- docker

before_install:
- git clone https://github.com/lean-delivery/ansible-lint-rules.git ~/ansible-lint-rules

install:
- pip3 install --upgrade ansible==2.8.* docker
- pip3 install molecule==2.22
- pip3 install git+https://github.com/ansible/ansible-lint.git
- ansible --version
- ansible-lint --version

script:
- yamllint . -c .yamllint
- ansible-lint . -c .ansible-lint
- molecule test -s default

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
31 changes: 31 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
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
empty-lines:
max: 3
level: error
hyphens:
level: error
truthy: disable
comments: disable
comments-indentation: disable
indentation: disable
key-duplicates: enable
line-length:
max: 150
level: warning
new-lines:
type: unix
185 changes: 185 additions & 0 deletions molecule/cloud-aws-direct/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
driver:
name: ec2
lint:
name: yamllint
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-ansible-beats
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family

- name: test-aws-centos7-ansible-beats
image: ami-9887c6e7
platform: centos7
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family

# - name: test-aws-centos6-ansible-beats
# image: ami-1585c46a
# platform: centos6
# instance_type: m4.large
# region: us-east-1
# vpc_subnet_id: subnet-0f2b9cd66faea38af
# assign_public_ip: false
# spot_price: 0.04
# security_group_name:
# - default
# wait_timeout: 1800
# ssh_user: centos
# groups:
# - rhel_family

- name: test-aws-ubuntu16-ansible-beats
image: ami-09677e0a6b14905b0
platform: ubuntu16
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
security_group_name:
- default
spot_price: 0.04
wait_timeout: 1800
ssh_user: ubuntu
groups:
- debian_family

- name: test-aws-ubuntu18-ansible-beats
image: ami-012fd5eb46f56731f
platform: ubuntu18
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
security_group_name:
- default
spot_price: 0.04
wait_timeout: 1800
ssh_user: ubuntu
groups:
- debian_family

- name: test-aws-Debian9-ansible-beats
image: ami-003f19e0e687de1cd
platform: debian9
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: admin
groups:
- debian_family

- name: test-aws-Amazon-ansible-beats
image: ami-035b3c7efe6d061d5
platform: amazon
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: ec2-user
groups:
- rhel_family

- name: test-aws-Amazon2-ansible-beats
image: ami-0b898040803850657
platform: amazon2
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: ec2-user
groups:
- rhel_family

# - name: test-aws-Windows2016-ansible-beats
# image_id: ami-00a20f508263efd30
# platform: windows2016core
# region: us-east-1
# instance_type: m5.large
# vpc_subnet_id: subnet-0f2b9cd66faea38af
# assign_public_ip: false
# spot_price: 0.14
# security_group_name:
# - default
# wait_timeout: 1800
# groups:
# - windows

# - name: test-aws-Windows2019-ansible-beats
# image_id: ami-0477b9335a5a75438
# platform: windows2019core
# region: us-east-1
# instance_type: m5.large
# vpc_subnet_id: subnet-0f2b9cd66faea38af
# assign_public_ip: false
# spot_price: 0.14
# security_group_name:
# - default
# wait_timeout: 1800
# groups:
# - windows
provisioner:
name: ansible
log: true
config_options:
defaults:
callback_whitelist: profile_tasks,timer
inventory:
group_vars:
windows:
ansible_connection: winrm
ansible_password: "{{ lookup('env', 'WINRM_ADMIN_PWD') | default('M0leCule123!', true) }}"
ansible_winrm_transport: credssp
ansible_winrm_server_cert_validation: ignore
playbooks:
create: ../resources/provisioning/AWS/create.yml
prepare: ../resources/provisioning/AWS/prepare.yml
destroy: ../resources/provisioning/AWS/destroy.yml
verify: ../resources/tests/verify.yml
lint:
name: ansible-lint
scenario:
name: cloud-aws-direct
verifier:
name: ansible
lint:
name: ansible-lint
5 changes: 5 additions & 0 deletions molecule/cloud-aws-direct/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: ansible-beats
62 changes: 62 additions & 0 deletions molecule/cloud-azure-direct/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
driver:
name: azure
lint:
name: yamllint
options:
config-file: .yamllint
platforms:

- name: test-azure-Windows2016-ansible-beats
platform: windows2016core
assign_public_ip: false
vm_size: Standard_D2s_v3
az_location: northeurope
az_resource_group_name: epm-ldi
az_virtual_network_name: epm-ldi-northeurope-vnet
az_subnet_name: epm-ldi-northeurope-subnet
az_network_security_group: epm-ldi-northeurope-sg
groups:
- windows

- name: test-azure-Windows2019-ansible-beats
platform: windows2019core
assign_public_ip: true
vm_size: Standard_D2s_v3
az_location: northeurope
az_resource_group_name: epm-ldi
az_virtual_network_name: epm-ldi-northeurope-vnet
az_subnet_name: epm-ldi-northeurope-subnet
az_network_security_group: epm-ldi-northeurope-sg
groups:
- windows
provisioner:
name: ansible
log: true
config_options:
defaults:
callback_whitelist: profile_tasks,timer
inventory:
group_vars:
windows:
ansible_connection: winrm
ansible_password: "{{ lookup('env', 'WINRM_ADMIN_PWD') | default('M0leCule123!', true) }}"
ansible_winrm_transport: credssp
ansible_winrm_server_cert_validation: ignore
playbooks:
create: ../resources/provisioning/AZURE/create.yml
prepare: ../resources/provisioning/AZURE/prepare.yml
destroy: ../resources/provisioning/AZURE/destroy.yml
verify: ../resources/tests/verify.yml
lint:
name: ansible-lint
scenario:
name: cloud-azure-direct
verifier:
name: ansible
lint:
name: ansible-lint
5 changes: 5 additions & 0 deletions molecule/cloud-azure-direct/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: ansible-beats
17 changes: 17 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Molecule managed

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

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash util-linux && 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 && 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 && xbps-remove -O; fi

RUN if [ -f /sbin/agetty ]; then cp /bin/true /sbin/agetty; \
elif [ -f /sbin/mingetty ]; then cp /bin/true /sbin/mingetty; fi

0 comments on commit 22a5738

Please sign in to comment.