fix ec2 pipeline
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Robert Kaussow 2019-05-12 01:28:24 +02:00
parent dcdb6755c0
commit 6701873db2
4 changed files with 71 additions and 52 deletions

View File

@ -48,9 +48,9 @@ local PipelineDeployment = {
image: "xoxys/molecule:ec2-linux-amd64", image: "xoxys/molecule:ec2-linux-amd64",
pull: "always", pull: "always",
environment: { environment: {
EC2_ACCESS_KEY: { "from_secret": "ec2_access_key" }, AWS_ACCESS_KEY_ID: { "from_secret": "aws_access_key_id" },
EC2_SECURITY_TOKEN: { "from_secret": "ec2_security_token" }, AWS_SECRET_ACCESS_KEY: { "from_secret": "aws_secret_access_key" },
EC2_REGION: "eu-central-1", AWS_REGION: "eu-central-1",
MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules", MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules",
PY_COLORS: 1 PY_COLORS: 1
}, },

View File

@ -1,41 +1,41 @@
#--- ---
#kind: pipeline kind: pipeline
#name: linting name: linting
#
#platform: platform:
# os: linux os: linux
# arch: amd64 arch: amd64
#
#steps: steps:
#- name: ansible-latest - name: ansible-latest
# pull: always pull: always
# image: python:3.7 image: python:3.7
# commands: commands:
# - pip install ansible ansible-later~=0.2.0 -qq - pip install ansible ansible-later~=0.2.0 -qq
# - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
# - ansible-later -c ~/policy/config.yml - ansible-later -c ~/policy/config.yml
# environment: environment:
# PY_COLORS: 1 PY_COLORS: 1
# depends_on: depends_on:
# - clone - clone
#
#- name: ansible-master - name: ansible-master
# pull: always pull: always
# image: python:3.7 image: python:3.7
# commands: commands:
# - "pip install git+https://github.com/ansible/ansible.git@devel ansible-later~=0.2.0 -qq" - "pip install git+https://github.com/ansible/ansible.git@devel ansible-later~=0.2.0 -qq"
# - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
# - ansible-later -c ~/policy/config.yml - ansible-later -c ~/policy/config.yml
# environment: environment:
# PY_COLORS: 1 PY_COLORS: 1
# depends_on: depends_on:
# - clone - clone
#
#trigger: trigger:
# ref: ref:
# - refs/heads/master - refs/heads/master
# - "refs/tags/**" - "refs/tags/**"
# - "refs/pull/**" - "refs/pull/**"
--- ---
kind: pipeline kind: pipeline
@ -60,11 +60,10 @@ steps:
- molecule destroy --scenario-name ec2-centos-7 - molecule destroy --scenario-name ec2-centos-7
environment: environment:
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: ec2_access_key from_secret: aws_access_key_id
EC2_REGION: eu-central-1 AWS_REGION: eu-central-1
AWS_SECRET_ACCESS_KEY: AWS_SECRET_ACCESS_KEY:
from_secret: ec2_security_token from_secret: aws_secret_access_key
MOLECULE_DEBUG: True
MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules
PY_COLORS: 1 PY_COLORS: 1
@ -73,8 +72,8 @@ trigger:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - "refs/tags/**"
#depends_on: depends_on:
#- linting - linting
--- ---
kind: pipeline kind: pipeline

View File

@ -1,5 +1,8 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
vars:
nginx_default_page_enabled: True
roles: roles:
- role: xoxys.nginx - role: xoxys.nginx

View File

@ -2,13 +2,30 @@ import os
import testinfra.utils.ansible_runner import testinfra.utils.ansible_runner
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hosts_file(host): def test_nginx_is_installed(host):
f = host.file('/etc/hosts') nginx = host.package("nginx")
assert nginx.is_installed
def test_nginx_running_and_enabled(host):
nginx = host.service("nginx")
assert nginx.is_running
assert nginx.is_enabled
def test_nginx_process(host):
# Verify worker procs are running
master = host.process.get(user="root", comm="nginx")
workers = host.process.filter(ppid=master.pid)
assert len(workers) > 0
def test_nginx_socket(host):
# Verify the socket is listening for HTTP traffic
assert host.socket("tcp://0.0.0.0:80").is_listening
assert f.exists
assert f.user == 'root'
assert f.group == 'root'