From 6701873db225083a724d5258175ffa962dee8261 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 12 May 2019 01:28:24 +0200 Subject: [PATCH] fix ec2 pipeline --- .drone.jsonnet | 6 +- .drone.yml | 87 ++++++++++----------- molecule/ec2-centos-7/playbook.yml | 3 + molecule/ec2-centos-7/tests/test_default.py | 27 +++++-- 4 files changed, 71 insertions(+), 52 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index d7ee467..b0a9a52 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -48,9 +48,9 @@ local PipelineDeployment = { image: "xoxys/molecule:ec2-linux-amd64", pull: "always", environment: { - EC2_ACCESS_KEY: { "from_secret": "ec2_access_key" }, - EC2_SECURITY_TOKEN: { "from_secret": "ec2_security_token" }, - EC2_REGION: "eu-central-1", + AWS_ACCESS_KEY_ID: { "from_secret": "aws_access_key_id" }, + AWS_SECRET_ACCESS_KEY: { "from_secret": "aws_secret_access_key" }, + AWS_REGION: "eu-central-1", MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules", PY_COLORS: 1 }, diff --git a/.drone.yml b/.drone.yml index df7f791..312287b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,41 +1,41 @@ -#--- -#kind: pipeline -#name: linting -# -#platform: -# os: linux -# arch: amd64 -# -#steps: -#- name: ansible-latest -# pull: always -# image: python:3.7 -# commands: -# - pip install ansible ansible-later~=0.2.0 -qq -# - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy -# - ansible-later -c ~/policy/config.yml -# environment: -# PY_COLORS: 1 -# depends_on: -# - clone -# -#- name: ansible-master -# pull: always -# image: python:3.7 -# commands: -# - "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 -# - ansible-later -c ~/policy/config.yml -# environment: -# PY_COLORS: 1 -# depends_on: -# - clone -# -#trigger: -# ref: -# - refs/heads/master -# - "refs/tags/**" -# - "refs/pull/**" +--- +kind: pipeline +name: linting + +platform: + os: linux + arch: amd64 + +steps: +- name: ansible-latest + pull: always + image: python:3.7 + commands: + - pip install ansible ansible-later~=0.2.0 -qq + - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy + - ansible-later -c ~/policy/config.yml + environment: + PY_COLORS: 1 + depends_on: + - clone + +- name: ansible-master + pull: always + image: python:3.7 + commands: + - "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 + - ansible-later -c ~/policy/config.yml + environment: + PY_COLORS: 1 + depends_on: + - clone + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" --- kind: pipeline @@ -60,11 +60,10 @@ steps: - molecule destroy --scenario-name ec2-centos-7 environment: AWS_ACCESS_KEY_ID: - from_secret: ec2_access_key - EC2_REGION: eu-central-1 + from_secret: aws_access_key_id + AWS_REGION: eu-central-1 AWS_SECRET_ACCESS_KEY: - from_secret: ec2_security_token - MOLECULE_DEBUG: True + from_secret: aws_secret_access_key MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules PY_COLORS: 1 @@ -73,8 +72,8 @@ trigger: - refs/heads/master - "refs/tags/**" -#depends_on: -#- linting +depends_on: +- linting --- kind: pipeline diff --git a/molecule/ec2-centos-7/playbook.yml b/molecule/ec2-centos-7/playbook.yml index bebc4b5..71caa98 100644 --- a/molecule/ec2-centos-7/playbook.yml +++ b/molecule/ec2-centos-7/playbook.yml @@ -1,5 +1,8 @@ --- - name: Converge hosts: all + vars: + nginx_default_page_enabled: True + roles: - role: xoxys.nginx diff --git a/molecule/ec2-centos-7/tests/test_default.py b/molecule/ec2-centos-7/tests/test_default.py index eedd64a..1ea751e 100644 --- a/molecule/ec2-centos-7/tests/test_default.py +++ b/molecule/ec2-centos-7/tests/test_default.py @@ -2,13 +2,30 @@ import os import testinfra.utils.ansible_runner +import warnings +warnings.filterwarnings("ignore", category=DeprecationWarning) + testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') -def test_hosts_file(host): - f = host.file('/etc/hosts') +def test_nginx_is_installed(host): + 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'