Skip to content

Commit

Permalink
Working on upgrades software (#55)
Browse files Browse the repository at this point in the history
Updated role to work with the latest version of Ansible and the latest version of Goss
  • Loading branch information
marcinpraczko authored Nov 17, 2023
1 parent c27ebd2 commit 9a32312
Show file tree
Hide file tree
Showing 24 changed files with 236 additions and 211 deletions.
3 changes: 1 addition & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[bumpversion]
current_version = 0.1.5
current_version = 0.1.6
commit = True
tag = True

[bumpversion:file:VERSION]

[bumpversion:file:README.md]

48 changes: 48 additions & 0 deletions .github/workflows/molecule-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Molecule Test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pwd
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Details about molecule
run: |
echo ""
echo "Molecule version"
molecule --version
echo ""
echo "Molecule drivers"
molecule drivers
echo ""
echo "Molecule list"
molecule list
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

- name: Test with molecule
run: molecule test -- -v
env:
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_STDOUT_CALLBACK: yaml
PY_COLORS: '1'
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ help: ## HELP: Show this help message
@echo '========'
@egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'


.PHONY: bump-version-patch
bump-version-patch: ## DEVELOP: Bump version - patch level
bumpversion patch


.PHONY: create-python3-venv
create-python3-venv: ## DEVELOP: Create python venv and install PIP packages
.PHONY: python3-create-venv
python3-create-venv: ## DEVELOP: Create python venv and install PIP packages
scripts/create-python3-venv.sh

# .PHONY: test-molecule
# test-molecule: ## DEVELOP: Test installing role with molecule
# molecule test
.PHONY: test-molecule
test-molecule: ## DEVELOP: Test installing role with molecule
molecule test
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Ansible-goss-install

**Version 0.1.5**
**Version 0.1.6**

This role aims to help with installation of validation tool: ``goss`` (Version: 0.3.18)

Expand Down Expand Up @@ -86,10 +86,16 @@ Following example will install ``goss`` in system: ``/usr/local/bin``:
This role can be tested via ``molecule`` with commands (Following commands will install it):
```bash
make create-python-venv
make test-molecule
make python3-create-venv
make test-molecule # WARNING: This is using default driver - which is ansible,
# this means that testing role equals running it on your machine like installation.
```

For more detail about molecule, please visit:

- [Molecule](https://molecule.readthedocs.io/en/latest/)

## Resources

- https://ansible.readthedocs.io/projects/molecule/ci/
- https://ansible.readthedocs.io/projects/molecule/getting-started/
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.1.4
VERSION=0.1.6
6 changes: 6 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]

# Use the YAML callback plugin.
stdout_callback = yaml
# Use the stdout_callback when running ad-hoc commands.
bin_ansible_callbacks = True
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ goss_dst_dir: bin/
goss_dst_dir_mode: 0755

# Latest version
goss_version: v0.3.18
goss_sha256sum: 432308ebca0caf8165d45bd27e3262126aad9d15572ac8cb3149b3c91f75aace
goss_version: v0.4.4
goss_sha256sum: 1c4f54b22fde9d4d5687939abc2606b0660a5d14a98afcd09b04b793d69acdc5

# OLD - Add choices here in some point
# goss_version: v0.3.18
# goss_sha256sum: 432308ebca0caf8165d45bd27e3262126aad9d15572ac8cb3149b3c91f75aace
# goss_version: v0.3.8
# goss_sha256sum: 4c82470543350371531f26f9d3b0265bff9e93d80d952f40cca212fc2f87864d
# goss_version: v0.3.7
Expand Down
6 changes: 4 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
galaxy_info:
author: Marcin Praczko
role_name: goss-install
namespace: marcinpraczko
description: Simple role to install binary goss file
author: Marcin Praczko
license: GNU GPLv2
min_ansible_version: 2.0
min_ansible_version: 2.15

platforms:
- name: EL
Expand Down
23 changes: 0 additions & 23 deletions molecule/default/INSTALL.rst

This file was deleted.

8 changes: 8 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: all
connection: local
gather_facts: false

roles:
- role: marcinpraczko.goss-install
36 changes: 36 additions & 0 deletions molecule/default/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
# no_log: "{{ molecule_no_log }}"
tasks:

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

- name: Create instance config
when: server.changed | default(false) | bool # noqa no-handler
block:
- name: Populate instance config dict # noqa jinja
ansible.builtin.set_fact:
instance_conf_dict: {}
# instance': "{{ }}",
# address': "{{ }}",
# user': "{{ }}",
# port': "{{ }}",
# 'identity_file': "{{ }}", }
with_items: "{{ server.results }}"
register: instance_config_dict

- name: Convert instance config dict to a list
ansible.builtin.set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"

- name: Dump instance config
ansible.builtin.copy:
content: |
# Molecule managed
{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
mode: 0600
24 changes: 24 additions & 0 deletions molecule/default/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
# no_log: "{{ molecule_no_log }}"
tasks:
# Developer must implement.

# Mandatory configuration for Molecule to function.

- name: Populate instance config
ansible.builtin.set_fact:
instance_conf: {}

- name: Dump instance config
ansible.builtin.copy:
content: |
# Molecule managed
{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
mode: 0600
when: server.changed | default(false) | bool # noqa no-handler
28 changes: 13 additions & 15 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint:
name: yamllint
# https://stackoverflow.com/questions/69652451/molecule-error-computed-fully-qualified-role-name-does-not-follow-current-galax
role_name_check: 1

platforms:
- name: centos7
box: centos/7
- name: ubuntu1804
box: generic/ubuntu1804
- name: instance
# you might want to add your own variables here based on what provisioning
# you are doing like:
# image: quay.io/centos/centos:stream8

provisioner:
name: ansible
log: true
lint:
name: ansible-lint

verifier:
name: goss
lint:
name: yamllint
name: testinfra
additional_files_or_dirs:
- ../path/to/test_1.py
32 changes: 0 additions & 32 deletions molecule/default/playbook.yml

This file was deleted.

9 changes: 0 additions & 9 deletions molecule/default/prepare.yml

This file was deleted.

17 changes: 0 additions & 17 deletions molecule/default/tests/test_default.yml

This file was deleted.

Loading

0 comments on commit 9a32312

Please sign in to comment.