Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaassssiiee committed Dec 12, 2022
1 parent 3de9154 commit 82f92f6
Show file tree
Hide file tree
Showing 32 changed files with 317 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .ansible-lint
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
4 changes: 2 additions & 2 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: molecule
Expand All @@ -27,7 +27,7 @@ jobs:
fail-fast: false
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: molecule
Expand Down
39 changes: 10 additions & 29 deletions .yamllint
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/
97 changes: 97 additions & 0 deletions molecule/azure/create.yml
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 }}"
29 changes: 29 additions & 0 deletions molecule/azure/destroy.yml
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
17 changes: 17 additions & 0 deletions molecule/azure/molecule.yml
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/
8 changes: 0 additions & 8 deletions molecule/centos8/converge.yml

This file was deleted.

14 changes: 12 additions & 2 deletions molecule/centos8/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ lint: |
ansible-lint
platforms:
- name: conda_centos8
image: docker.io/pycontribs/centos:8
pre_build_image: true
image: quay.io/centos/centos:stream8
command: /sbin/init
privileged: true
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
playbooks:
converge: ../shared/converge.yml
verify: ../shared/verify.yml
verifier:
name: ansible
directory: ../shared/tests/
...
8 changes: 0 additions & 8 deletions molecule/debian10/converge.yml

This file was deleted.

4 changes: 4 additions & 0 deletions molecule/debian10/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ platforms:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
playbooks:
converge: ../shared/converge.yml
verify: ../shared/verify.yml
verifier:
name: ansible
directory: ../shared/tests/
...
8 changes: 0 additions & 8 deletions molecule/default/converge.yml

This file was deleted.

5 changes: 4 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ lint: |
set -e
yamllint .
ansible-lint
ansible-later -qq
platforms:
- name: conda_centos7
image: centos:7
privileged: true
provisioner:
name: ansible
playbooks:
converge: ../shared/converge.yml
verify: ../shared/verify.yml
verifier:
name: ansible
directory: ../shared/tests/
...
8 changes: 0 additions & 8 deletions molecule/fedora31/converge.yml

This file was deleted.

4 changes: 4 additions & 0 deletions molecule/fedora31/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ platforms:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
playbooks:
converge: ../shared/converge.yml
verify: ../shared/verify.yml
verifier:
name: ansible
directory: ../shared/tests/
...
15 changes: 0 additions & 15 deletions molecule/macos/INSTALL.rst

This file was deleted.

8 changes: 0 additions & 8 deletions molecule/macos/converge.yml

This file was deleted.

5 changes: 3 additions & 2 deletions molecule/macos/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

# TODO: Developer must implement and populate 'server' variable

- when: server.changed | default(false) | bool
- name: Configure molecule # noqa no-handler
when: server.changed | default(false) | bool
block:
- name: Populate instance config dict
set_fact:
Expand All @@ -17,7 +18,7 @@
'address': "{{ }}",
'user': "{{ }}",
'port': "{{ }}",
'identity_file': "{{ }}", }
'identity_file': "{{ }}"}
with_items: "{{ server.results }}"
register: instance_config_dict

Expand Down
7 changes: 6 additions & 1 deletion molecule/macos/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ lint: |
set -e
yamllint .
ansible-lint
ansible-later
platforms:
- name: localhost
provisioner:
name: ansible
playbooks:
create: create.yml
converge: ../shared/converge.yml
verify: ../shared/verify.yml
destroy: destroy.yml
verifier:
name: ansible
directory: ../shared/tests/
...
11 changes: 11 additions & 0 deletions molecule/shared/converge.yml
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 }}"
Loading

0 comments on commit 82f92f6

Please sign in to comment.