This commit is contained in:
parent
51277b11a6
commit
2f26a78cbd
@ -1,22 +0,0 @@
|
|||||||
*******
|
|
||||||
Amazon Web Services driver installation guide
|
|
||||||
*******
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
============
|
|
||||||
|
|
||||||
* An AWS credentials rc file
|
|
||||||
|
|
||||||
Install
|
|
||||||
=======
|
|
||||||
|
|
||||||
Please refer to the `Virtual environment`_ documentation for installation best
|
|
||||||
practices. If not using a virtual environment, please consider passing the
|
|
||||||
widely recommended `'--user' flag`_ when invoking ``pip``.
|
|
||||||
|
|
||||||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
|
||||||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ pip install 'molecule[ec2]'
|
|
@ -1,22 +0,0 @@
|
|||||||
*******
|
|
||||||
Amazon Web Services driver installation guide
|
|
||||||
*******
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
============
|
|
||||||
|
|
||||||
* An AWS credentials rc file
|
|
||||||
|
|
||||||
Install
|
|
||||||
=======
|
|
||||||
|
|
||||||
Please refer to the `Virtual environment`_ documentation for installation best
|
|
||||||
practices. If not using a virtual environment, please consider passing the
|
|
||||||
widely recommended `'--user' flag`_ when invoking ``pip``.
|
|
||||||
|
|
||||||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
|
||||||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ pip install 'molecule[ec2]'
|
|
@ -1,124 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Create
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
gather_facts: false
|
|
||||||
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
|
||||||
vars:
|
|
||||||
ssh_user: centos
|
|
||||||
ssh_port: 22
|
|
||||||
|
|
||||||
security_group_name: molecule
|
|
||||||
security_group_description: Security group for testing Molecule
|
|
||||||
security_group_rules:
|
|
||||||
- proto: tcp
|
|
||||||
from_port: "{{ ssh_port }}"
|
|
||||||
to_port: "{{ ssh_port }}"
|
|
||||||
cidr_ip: '0.0.0.0/0'
|
|
||||||
- proto: icmp
|
|
||||||
from_port: 8
|
|
||||||
to_port: -1
|
|
||||||
cidr_ip: '0.0.0.0/0'
|
|
||||||
security_group_rules_egress:
|
|
||||||
- proto: -1
|
|
||||||
from_port: 0
|
|
||||||
to_port: 0
|
|
||||||
cidr_ip: '0.0.0.0/0'
|
|
||||||
|
|
||||||
keypair_name: molecule_key_certbot
|
|
||||||
keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
|
||||||
tasks:
|
|
||||||
- name: Create security group
|
|
||||||
ec2_group:
|
|
||||||
name: "{{ security_group_name }}"
|
|
||||||
description: "{{ security_group_name }}"
|
|
||||||
rules: "{{ security_group_rules }}"
|
|
||||||
rules_egress: "{{ security_group_rules_egress }}"
|
|
||||||
|
|
||||||
- name: Delete remote keypair
|
|
||||||
ec2_key:
|
|
||||||
name: "{{ keypair_name }}"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Create keypair
|
|
||||||
ec2_key:
|
|
||||||
name: "{{ keypair_name }}"
|
|
||||||
register: keypair
|
|
||||||
|
|
||||||
- name: Persist the keypair
|
|
||||||
copy:
|
|
||||||
dest: "{{ keypair_path }}"
|
|
||||||
content: "{{ keypair.key.private_key }}"
|
|
||||||
mode: 0600
|
|
||||||
when: keypair.changed
|
|
||||||
|
|
||||||
- name: Create molecule instance(s)
|
|
||||||
ec2:
|
|
||||||
key_name: "{{ keypair_name }}"
|
|
||||||
image: "{{ item.image }}"
|
|
||||||
instance_type: "{{ item.instance_type }}"
|
|
||||||
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
|
|
||||||
group: "{{ security_group_name }}"
|
|
||||||
instance_tags:
|
|
||||||
instance: "{{ item.name }}"
|
|
||||||
wait: true
|
|
||||||
assign_public_ip: true
|
|
||||||
exact_count: 1
|
|
||||||
count_tag:
|
|
||||||
instance: "{{ item.name }}"
|
|
||||||
volumes:
|
|
||||||
- device_name: /dev/sda1
|
|
||||||
volume_type: gp2
|
|
||||||
volume_size: 8
|
|
||||||
delete_on_termination: yes
|
|
||||||
register: server
|
|
||||||
with_items: "{{ molecule_yml.platforms }}"
|
|
||||||
async: 7200
|
|
||||||
poll: 0
|
|
||||||
|
|
||||||
- name: Wait for instance(s) creation to complete
|
|
||||||
async_status:
|
|
||||||
jid: "{{ item.ansible_job_id }}"
|
|
||||||
register: ec2_jobs
|
|
||||||
until: ec2_jobs.finished
|
|
||||||
retries: 300
|
|
||||||
with_items: "{{ server.results }}"
|
|
||||||
|
|
||||||
# Mandatory configuration for Molecule to function.
|
|
||||||
|
|
||||||
- name: Populate instance config dict
|
|
||||||
set_fact:
|
|
||||||
instance_conf_dict: {
|
|
||||||
'instance': "{{ item.instances[0].tags.instance }}",
|
|
||||||
'address': "{{ item.instances[0].public_ip }}",
|
|
||||||
'user': "{{ ssh_user }}",
|
|
||||||
'port': "{{ ssh_port }}",
|
|
||||||
'identity_file': "{{ keypair_path }}",
|
|
||||||
'instance_ids': "{{ item.instance_ids }}", }
|
|
||||||
with_items: "{{ ec2_jobs.results }}"
|
|
||||||
register: instance_config_dict
|
|
||||||
when: server.changed | bool
|
|
||||||
|
|
||||||
- name: Convert instance config dict to a list
|
|
||||||
set_fact:
|
|
||||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
|
||||||
when: server.changed | bool
|
|
||||||
|
|
||||||
- name: Dump instance config
|
|
||||||
copy:
|
|
||||||
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
|
||||||
dest: "{{ molecule_instance_config }}"
|
|
||||||
when: server.changed | bool
|
|
||||||
|
|
||||||
- name: Wait for SSH
|
|
||||||
wait_for:
|
|
||||||
port: "{{ ssh_port }}"
|
|
||||||
host: "{{ item.address }}"
|
|
||||||
search_regex: SSH
|
|
||||||
delay: 10
|
|
||||||
timeout: 320
|
|
||||||
with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
|
||||||
|
|
||||||
- name: Wait for boot process to finish
|
|
||||||
pause:
|
|
||||||
minutes: 2
|
|
@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Destroy
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
gather_facts: false
|
|
||||||
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
|
||||||
tasks:
|
|
||||||
- block:
|
|
||||||
- name: Populate instance config
|
|
||||||
set_fact:
|
|
||||||
instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
|
||||||
skip_instances: false
|
|
||||||
rescue:
|
|
||||||
- name: Populate instance config when file missing
|
|
||||||
set_fact:
|
|
||||||
instance_conf: {}
|
|
||||||
skip_instances: true
|
|
||||||
|
|
||||||
- name: Destroy molecule instance(s)
|
|
||||||
ec2:
|
|
||||||
state: absent
|
|
||||||
instance_ids: "{{ item.instance_ids }}"
|
|
||||||
register: server
|
|
||||||
with_items: "{{ instance_conf }}"
|
|
||||||
when: not skip_instances
|
|
||||||
async: 7200
|
|
||||||
poll: 0
|
|
||||||
|
|
||||||
- name: Wait for instance(s) deletion to complete
|
|
||||||
async_status:
|
|
||||||
jid: "{{ item.ansible_job_id }}"
|
|
||||||
register: ec2_jobs
|
|
||||||
until: ec2_jobs.finished
|
|
||||||
retries: 300
|
|
||||||
with_items: "{{ server.results }}"
|
|
||||||
|
|
||||||
# Mandatory configuration for Molecule to function.
|
|
||||||
|
|
||||||
- name: Populate instance config
|
|
||||||
set_fact:
|
|
||||||
instance_conf: {}
|
|
||||||
|
|
||||||
- name: Dump instance config
|
|
||||||
copy:
|
|
||||||
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
|
||||||
dest: "{{ molecule_instance_config }}"
|
|
||||||
when: server.changed | bool
|
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
dependency:
|
|
||||||
name: galaxy
|
|
||||||
driver:
|
|
||||||
name: ec2
|
|
||||||
platforms:
|
|
||||||
- name: centos-7-certbot
|
|
||||||
image: ami-04cf43aca3e6f3de3
|
|
||||||
instance_type: t2.micro
|
|
||||||
vpc_subnet_id: subnet-9b6896f1
|
|
||||||
lint:
|
|
||||||
name: yamllint
|
|
||||||
enabled: False
|
|
||||||
provisioner:
|
|
||||||
name: ansible
|
|
||||||
lint:
|
|
||||||
name: ansible-lint
|
|
||||||
enabled: False
|
|
||||||
verifier:
|
|
||||||
name: testinfra
|
|
||||||
lint:
|
|
||||||
name: flake8
|
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Converge
|
|
||||||
hosts: all
|
|
||||||
vars:
|
|
||||||
certbot_packages_extra:
|
|
||||||
- epel-release
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- role: xoxys.certbot
|
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Prepare
|
|
||||||
hosts: all
|
|
||||||
gather_facts: false
|
|
||||||
tasks:
|
|
||||||
- name: Install python for Ansible
|
|
||||||
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream)
|
|
||||||
become: true
|
|
||||||
changed_when: false
|
|
@ -1,14 +0,0 @@
|
|||||||
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_certbot_is_installed(host):
|
|
||||||
certbot = host.package("certbot")
|
|
||||||
assert certbot.is_installed
|
|
Loading…
Reference in New Issue
Block a user