Skip to content

Commit f82221f

Browse files
authored
Add ec2 plugin (#36)
1 parent d5fc949 commit f82221f

File tree

29 files changed

+1572
-2
lines changed

29 files changed

+1572
-2
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-22.04
3535
needs: pre
3636
env:
37-
PYTEST_REQPASS: 4
37+
PYTEST_REQPASS: 5
3838
strategy:
3939
fail-fast: false
4040
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}

doc/ec2/README.rst

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
*******************
2+
Molecule EC2 Plugin
3+
*******************
4+
5+
.. image:: https://badge.fury.io/py/molecule-ec2.svg
6+
:target: https://badge.fury.io/py/molecule-ec2
7+
:alt: PyPI Package
8+
9+
.. image:: https://zuul-ci.org/gated.svg
10+
:target: https://dashboard.zuul.ansible.com/t/ansible/builds?project=ansible-community/molecule-ec2
11+
12+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
13+
:target: https://github.com/python/black
14+
:alt: Python Black Code Style
15+
16+
.. image:: https://img.shields.io/badge/Code%20of%20Conduct-silver.svg
17+
:target: https://docs.ansible.com/ansible/latest/community/code_of_conduct.html
18+
:alt: Ansible Code of Conduct
19+
20+
.. image:: https://img.shields.io/badge/Mailing%20lists-silver.svg
21+
:target: https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information
22+
:alt: Ansible mailing lists
23+
24+
.. image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
25+
:target: LICENSE
26+
:alt: Repository License
27+
28+
Molecule EC2 is designed to allow use of AWS EC2 for provisioning of test
29+
resources.
30+
31+
.. _quickstart:
32+
33+
Quickstart
34+
==========
35+
36+
Installation
37+
------------
38+
.. code-block:: bash
39+
40+
pip install molecule-ec2
41+
42+
Create a scenario
43+
-----------------
44+
45+
With a new role
46+
^^^^^^^^^^^^^^^
47+
.. code-block:: bash
48+
49+
molecule init role -d ec2 my-role
50+
51+
This will create a new folder *my-role* containing a bare-bone generated
52+
role like you would do with ``ansible-galaxy init`` command.
53+
It will also contain a molecule folder with a default scenario
54+
using the ec2 driver (using ansible community.aws.ec2_instance collection).
55+
Install the collection using
56+
`ansible-galaxy install -r test_requirements.yml`.
57+
58+
In a pre-existing role
59+
^^^^^^^^^^^^^^^^^^^^^^
60+
.. code-block:: bash
61+
62+
molecule init scenario -d ec2
63+
64+
This will create a default scenario with the ec2 driver in a molecule folder,
65+
located in the current working directory.
66+
67+
Example
68+
-------
69+
This is a molecule.yml example file
70+
71+
.. code-block:: yaml
72+
73+
dependency:
74+
name: galaxy
75+
driver:
76+
name: ec2
77+
platforms:
78+
- name: instance
79+
image_owner: "099720109477"
80+
image_name: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*
81+
instance_type: t2.micro
82+
vpc_subnet_id: <your-aws-vpc-subnet-id>
83+
tags:
84+
Name: molecule_instance
85+
provisioner:
86+
name: ansible
87+
verifier:
88+
name: ansible
89+
90+
All you need to do is fill in the subnet-id you want
91+
to create your test instance into.
92+
Then run
93+
94+
.. code-block:: bash
95+
96+
molecule test
97+
98+
.. note::
99+
To make this work, you need to export your AWS credentials, as well as the AWS region you want to use, in your environment.
100+
101+
.. code-block:: bash
102+
103+
export AWS_ACCESS_KEY_ID=ACCESS_API_KEY
104+
export AWS_SECRET_KEY=SECRET_API_KEY
105+
export AWS_REGION=us-east-1
106+
107+
You can read more about managing AWS credentials with Ansible modules
108+
in the official documentation of the `Ansible AWS modules <https://docs.ansible.com/ansible/latest/collections/amazon/aws>`_
109+
110+
Documentation
111+
=============
112+
113+
Details on the parameters for the platforms section are detailed in
114+
`<platforms.rst>`__.
115+
116+
Read the molecule documentation and more at https://molecule.readthedocs.io/.
117+
118+
.. _get-involved:
119+
120+
Get Involved
121+
============
122+
123+
* Join us in the ``#ansible-molecule`` channel on `Freenode`_.
124+
* Join the discussion in `molecule-users Forum`_.
125+
* Join the community working group by checking the `wiki`_.
126+
* Want to know about releases, subscribe to `ansible-announce list`_.
127+
* For the full list of Ansible email Lists, IRC channels see the
128+
`communication page`_.
129+
130+
.. _`Freenode`: https://freenode.net
131+
.. _`molecule-users Forum`: https://groups.google.com/forum/#!forum/molecule-users
132+
.. _`wiki`: https://github.com/ansible/community/wiki/Molecule
133+
.. _`ansible-announce list`: https://groups.google.com/group/ansible-announce
134+
.. _`communication page`: https://docs.ansible.com/ansible/latest/community/communication.html
135+
136+
.. _authors:
137+
138+
Authors
139+
=======
140+
141+
Molecule EC2 Plugin was created by Sorin Sbarnea based on code from
142+
Molecule.
143+
144+
.. _license:
145+
146+
License
147+
=======
148+
149+
The `MIT`_ License.
150+
151+
.. _`MIT`: https://github.com/ansible/molecule/blob/master/LICENSE
152+
153+
The logo is licensed under the `Creative Commons NoDerivatives 4.0 License`_.
154+
155+
If you have some other use in mind, contact us.
156+
157+
.. _`Creative Commons NoDerivatives 4.0 License`: https://creativecommons.org/licenses/by-nd/4.0/

0 commit comments

Comments
 (0)