-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3de9154
commit 82f92f6
Showing
32 changed files
with
317 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
skip_list: | ||
- '204' # Lines should be no longer than 160 chars | ||
- experimental # all rules tagged as experimental | ||
- fqcn-builtins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
--- | ||
# Based on ansible-lint config | ||
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 | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
indentation: disable | ||
key-duplicates: enable | ||
line-length: disable | ||
new-line-at-end-of-file: disable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: disable | ||
truthy: disable | ||
line-length: | ||
max: 160 | ||
allow-non-breakable-words: true | ||
allow-non-breakable-inline-mappings: false | ||
truthy: | ||
allowed-values: ['true', 'false'] | ||
check-keys: false | ||
|
||
ignore: | | ||
.tox/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
# yamllint disable rule:line-length | ||
- name: Create | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
no_log: "{{ molecule_no_log }}" | ||
vars_files: | ||
- vars/main.yml | ||
|
||
tasks: | ||
- name: Create resource group | ||
azure_rm_resourcegroup: | ||
name: "{{ resource_group_name }}" | ||
location: "{{ arm_location }}" | ||
|
||
- name: Create virtual network | ||
azure_rm_virtualnetwork: | ||
resource_group: "{{ resource_group_name }}" | ||
name: "{{ virtual_network_name }}" | ||
address_prefixes: "10.7.0.0/16" | ||
|
||
- name: Create subnet | ||
azure_rm_subnet: | ||
resource_group: "{{ resource_group_name }}" | ||
name: "{{ subnet_name }}" | ||
address_prefix_cidr: 10.7.1.0/24 | ||
virtual_network_name: "{{ virtual_network_name }}" | ||
|
||
- name: Create key pair | ||
user: | ||
name: "{{ lookup('env', 'USER') }}" | ||
generate_ssh_key: true | ||
ssh_key_file: "{{ keypair_path }}" | ||
register: key_pair | ||
|
||
- name: Create molecule instance(s) | ||
azure_rm_virtualmachine: | ||
resource_group: "{{ resource_group_name }}" | ||
name: "{{ item.name }}" | ||
vm_size: "{{ vm_size }}" | ||
admin_username: "{{ ssh_user }}" | ||
public_ip_allocation_method: Dynamic | ||
ssh_password_enabled: false | ||
ssh_public_keys: | ||
- path: "/home/{{ ssh_user }}/.ssh/authorized_keys" | ||
key_data: "{{ key_pair.ssh_public_key }}" | ||
image: | ||
offer: CentOS | ||
publisher: OpenLogic | ||
sku: '7.4' | ||
version: latest | ||
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: azure_jobs | ||
until: azure_jobs.finished | ||
retries: 300 | ||
with_items: "{{ server.results }}" | ||
|
||
# Mandatory configuration for Molecule to function. | ||
- name: Populate instance config dict # noqa no-handler | ||
set_fact: | ||
instance_conf_dict: { | ||
'instance': "{{ item.ansible_facts.azure_vm.name }}", | ||
'address': "{{ item.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.publicIPAddress.properties.ipAddress }}", | ||
'user': "{{ ssh_user }}", | ||
'port': "{{ ssh_port }}", | ||
'identity_file': "{{ keypair_path }}"} | ||
with_items: "{{ azure_jobs.results }}" | ||
register: instance_config_dict | ||
when: server.changed | bool | ||
|
||
- name: Convert instance config dict to a list # noqa no-handler | ||
ansible.builtin.set_fact: | ||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" | ||
when: server.changed | bool | ||
|
||
- name: Dump instance config # noqa no-handler | ||
ansible.builtin.copy: | ||
content: "{{ instance_conf | to_json | from_json | to_yaml }}" | ||
dest: "{{ molecule_instance_config }}" | ||
mode: 0600 | ||
when: server.changed | bool | ||
|
||
- name: Wait for SSH | ||
ansible.builtin.wait_for: | ||
port: "{{ ssh_port }}" | ||
host: "{{ item.address }}" | ||
search_regex: SSH | ||
delay: 10 | ||
with_items: "{{ lookup('file', molecule_instance_config) | from_yaml }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Destroy | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
no_log: "{{ molecule_no_log }}" | ||
vars: | ||
resource_group_name: molecule | ||
virtual_network_name: molecule_vnet | ||
subnet_name: molecule_subnet | ||
tasks: | ||
- name: Destroy resource group and all associated resources | ||
azure_rm_resourcegroup: | ||
name: "{{ resource_group_name }}" | ||
state: absent | ||
force_delete_nonempty: true | ||
register: rg | ||
|
||
# Mandatory configuration for Molecule to function. | ||
|
||
- name: Populate instance config | ||
set_fact: | ||
instance_conf: {} | ||
|
||
- name: Dump instance config # noqa no-handler | ||
copy: | ||
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" | ||
dest: "{{ molecule_instance_config }}" | ||
when: rg.changed | bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: azure | ||
platforms: | ||
- name: instance | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
create: create.yml | ||
converge: ../shared/converge.yml | ||
verify: ../shared/verify.yml | ||
destroy: destroy.yml | ||
verifier: | ||
name: ansible | ||
directory: ../shared/tests/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
vars: | ||
role_name: "{{ lookup('env','MOLECULE_PROJECT_DIRECTORY') | basename }}" | ||
|
||
tasks: | ||
- name: "Include {{ role_name }}" | ||
ansible.builtin.include_role: | ||
name: "{{ role_name }}" |
Oops, something went wrong.