Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor platform logic #16

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---

name: Test and release branch
on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.12"]
molecule-scenario:
- default
- ec2_platform

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install molecule ansible-lint requests boto3[crt]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Build and install collection
run: |
ansible-galaxy collection build --force
ansible-galaxy collection install --force *-molecule-*.tar.gz

- name: Log into AWS
if: ${{ matrix.molecule-scenario == 'ec2_platform' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: Test with molecule
env:
# Make molecule output colored content (easier to read via GH UI)
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
molecule test -s ${{ matrix.molecule-scenario }}

deploy:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4

- name: Create and Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
TAG_NAME=${{ github.ref_name }}
echo "Creating tag $TAG_NAME"
# Configure Git user
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create the tag
git tag "$TAG_NAME"
# Push the tag to the repository
git push origin "refs/tags/$TAG_NAME" --force

27 changes: 0 additions & 27 deletions .github/workflows/latest-devel.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/latest.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/main.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

name: Deploy Collection
on:
release:
types:
- published

jobs:
deploy:
runs-on: ubuntu-latest
if: |
github.event.release.prerelase == false
steps:
- uses: actions/checkout@v4

- name: Tag latest release
uses: EndBug/latest-tag@latest
with:
ref: latest
description: This tag is automatically generated on new releases.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Deploy Collection
uses: artis3n/ansible_galaxy_collection@v2
if: ${{ secrets.GALAXY_API_KEY != '' }}
with:
api_key: '${{ secrets.GALAXY_API_KEY }}'

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
influxdata-molecule-*.tar.gz
*-molecule-*.tar.gz
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 InfluxData
Copyright (c) 2025 InfluxData

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ When utilizing an image with systemd support (systemd packages are installed, et

# Table of Contents

- [Ansible Collection - syndr.molecule](#ansible-collection---syndrmolecule)
- [Ansible Collection - influxdata.molecule](#ansible-collection---influxdatamolecule)
- [What is Molecule?](#what-is-molecule)
- [Using this collection](#using-this-collection)
- [Host Requirements](#host-requirements)
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace: influxdata
name: molecule

# The version of the collection. Must be compatible with semantic versioning
version: 1.4.2
version: 2.0.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
33 changes: 23 additions & 10 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,36 @@ driver:
name: default
options:
managed: true
login_cmd_template: 'docker exec -ti {instance} bash'
login_cmd_template: 'docker exec -ti {instance} bash --login'
platforms:
- name: docker-rockylinux9
- name: ansible-collection-molecule-docker-rockylinux9
type: docker
image: geerlingguy/docker-rockylinux9-ansible:latest
systemd: True
modify_image: False
privileged: False
hostvars:
test_hostvar: test
- name: docker-fedora39
- name: ansible-collection-molecule-docker-rockylinux9-customized
type: docker
image: geerlingguy/docker-fedora39-ansible:latest
image: rockylinux/rockylinux:9-ubi
systemd: True
modify_image: False
exec_systemd: True
exec_systemd_build_commands:
- dnf install -y sudo
privileged: False
hostvars:
test_hostvar: test
- name: docker-ubuntu2204
- name: ansible-collection-molecule-docker-fedora41
type: docker
image: geerlingguy/docker-fedora41-ansible:latest
systemd: True
privileged: False
hostvars:
test_hostvar: test
- name: ansible-collection-molecule-docker-ubuntu2204
type: docker
image: geerlingguy/docker-ubuntu2204-ansible:latest
systemd: True
modify_image: False
privileged: False
hostvars:
test_hostvar: test
Expand All @@ -38,7 +45,7 @@ provisioner:
playbooks:
create: ../resources/create.yml
prepare: ../resources/prepare.yml
converge: converge.yml
converge: ../resources/converge.yml
side_effect: ../resources/side_effect.yml
verify: ../resources/verify.yml
cleanup: ../resources/cleanup.yml
Expand All @@ -47,11 +54,17 @@ provisioner:
defaults:
gathering: explicit
verbosity: ${ANSIBLE_VERBOSITY:-0}
env:
ARA_API_CLIENT: ${ARA_API_CLIENT:-'http'}
ARA_API_SERVER: ${ARA_API_SERVER:-'http://localhost:8000'}
ARA_DEFAULT_LABELS: ${ARA_DEFAULT_LABELS:-'testing,molecule'}
# To use Ara with molecule:
# export the ANSIBLE_CALLBACK_PLUGINS env var with the output of 'python3 -m ara.setup.callback_plugins'
ANSIBLE_CALLBACK_PLUGINS: ${ANSIBLE_CALLBACK_PLUGINS}
scenario:
create_sequence:
- dependency
- create
- prepare
check_sequence:
- dependency
- cleanup
Expand Down
52 changes: 0 additions & 52 deletions molecule/ec2_platform/converge.yml

This file was deleted.

Loading
Loading