diff --git a/.ansible-lint b/.ansible-lint index 8fab004f8..eca30f05d 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,5 +1,10 @@ --- +profile: production + exclude_paths: - .github - .manala + +skip_list: + - var-naming[no-role-prefix] diff --git a/.env b/.env new file mode 100644 index 000000000..56f228935 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# Ansible Galaxy +ANSIBLE_GALAXY_TOKEN_PATH=galaxy_token diff --git a/.env.dist b/.env.dist deleted file mode 100644 index f325388dc..000000000 --- a/.env.dist +++ /dev/null @@ -1,2 +0,0 @@ -# Collection -#COLLECTION_API_TOKEN= diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..bc9a4d59b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/collection-release.yaml b/.github/workflows/collection-release.yaml deleted file mode 100644 index 59e7c45be..000000000 --- a/.github/workflows/collection-release.yaml +++ /dev/null @@ -1,153 +0,0 @@ -name: Collection Release - -on: - push: - branches: - - main - -jobs: - collection-build: - runs-on: ubuntu-22.04 - if: github.event.head_commit.message == 'Release' - steps: - - - name: Notify Slack of starting - uses: act10ns/slack@v2 - with: - status: starting - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - name: Checkout - uses: actions/checkout@v3 - - - name: Env - run: | - cp .env.dist .env - - - name: Set up system - uses: ./.manala/github/system/setup - - - name: Retrieve version from galaxy.yml - id: get_version - uses: CumulusDS/get-yaml-paths-action@v1.0.1 - with: - file: ./galaxy.yml - version: version - - - name: Build Collection - id: build_collection - run: | - make collection.build - - - name: Create artifact from collection build - uses: actions/upload-artifact@v3 - with: - path: ./manala-roles-${{ steps.get_version.outputs.version }}.tar.gz - name: manala-roles-${{ steps.get_version.outputs.version }} - retention-days: 1 - - - name: Notify Slack of job status - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() - - collection-publish: - needs: collection-build - runs-on: ubuntu-22.04 - if: github.event.head_commit.message == 'Release' - env: - COLLECTION_API_TOKEN: ${{ secrets.COLLECTION_API_TOKEN }} - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Env - run: | - cp .env.dist .env - - - name: Set up system - uses: ./.manala/github/system/setup - - - name: Retrieve version from galaxy.yml - id: get_version - uses: CumulusDS/get-yaml-paths-action@v1.0.1 - with: - file: ./galaxy.yml - version: version - - - name: Retrieve collection build from artifact - uses: actions/download-artifact@v3 - with: - name: manala-roles-${{ steps.get_version.outputs.version }} - - - name: Publish Collection - id: publish_collection - run: | - make collection.publish - - - name: Notify Slack of job status - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() - - github-release: - needs: collection-build - runs-on: ubuntu-22.04 - if: github.event.head_commit.message == 'Release' - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Retrieve version from galaxy.yml - id: get_version - uses: CumulusDS/get-yaml-paths-action@v1.0.1 - with: - file: ./galaxy.yml - version: version - - - name: Get Changelog Entry - id: changelog - uses: mindsers/changelog-reader-action@v2 - with: - path: ./CHANGELOG.md - version: ${{ steps.get_version.outputs.version }} - - - name: Retrieve collection build from artifact - uses: actions/download-artifact@v3 - with: - name: manala-roles-${{ steps.get_version.outputs.version }} - - - name: Create Github Release - id: github_release - uses: ncipollo/release-action@v1 - with: - name: manala-roles ${{ steps.get_version.outputs.version }} - tag: ${{ steps.get_version.outputs.version }} - body: ${{ steps.changelog.outputs.changes }} - artifacts: ./manala-roles-${{ steps.get_version.outputs.version }}.tar.gz - token: ${{ secrets.GITHUB_TOKEN }} - skipIfReleaseExists: true - - - name: Notify Slack of job status - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b278e878a..8380664f2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -7,15 +7,11 @@ on: jobs: lint: name: Lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Env - run: | - cp .env.dist .env + uses: actions/checkout@v4 - name: Set up system uses: ./.manala/github/system/setup diff --git a/.github/workflows/molecule.yaml b/.github/workflows/molecule.yaml index da9c5b035..66bcf2b2a 100644 --- a/.github/workflows/molecule.yaml +++ b/.github/workflows/molecule.yaml @@ -27,10 +27,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Env - run: | - cp .env.dist .env - - name: Set up system uses: ./.manala/github/system/setup diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..1ff69f489 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,76 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + release: + name: Release + runs-on: ubuntu-24.04 + if: github.event.head_commit.message == 'Release' + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set ansible galaxy token + run: | + cat << EOF > galaxy_token + token: ${{ secrets.ANSIBLE_GALAXY_TOKEN }} + EOF + + - name: Set up system + uses: ./.manala/github/system/setup + + - name: Get version + id: version + run: | + cat << EOF > $GITHUB_OUTPUT + version=$(make version) + EOF + + - name: Build + id: build + run: | + make build VERBOSE=1 + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + path: build/manala-roles-${{ steps.version.outputs.version }}.tar.gz + name: manala-roles-${{ steps.version.outputs.version }}.tar.gz + + - name: Publish + id: publish + run: | + make publish VERBOSE=1 + + - name: Get Changelog entry + id: changelog + uses: mindsers/changelog-reader-action@v2 + with: + path: CHANGELOG.md + version: ${{ steps.version.outputs.version }} + + - name: Create GitHub Release + id: release + uses: ncipollo/release-action@v1 + with: + name: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.version }} + body: ${{ steps.changelog.outputs.changes }} + artifacts: build/manala-roles-${{ steps.version.outputs.version }}.tar.gz + token: ${{ secrets.GITHUB_TOKEN }} + skipIfReleaseExists: true + + - name: Notify Slack - Status + uses: act10ns/slack@v2 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#collection_release' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + if: always() diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1213a6f07..b4efaa891 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,15 +7,11 @@ on: jobs: test: name: Test - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Env - run: | - cp .env.dist .env + uses: actions/checkout@v4 - name: Set up system uses: ./.manala/github/system/setup @@ -26,17 +22,12 @@ jobs: - name: Units run: | - make test.units VERBOSE=1 COVERAGE=1 + make test.units VERBOSE=1 - name: Integration run: | - make test.integration VERBOSE=1 COVERAGE=1 - - - name: Coverage - run: | - make test.coverage VERBOSE=1 + make test.integration VERBOSE=1 - - name: Codecov - uses: codecov/codecov-action@v2 - with: - fail_ci_if_error: false + # - name: Doc + # run: | + # make test.doc VERBOSE=1 diff --git a/.gitignore b/.gitignore index ef4df1364..5d3c568de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -.env -manala-roles-* +build/ +.env.local +galaxy_token diff --git a/.manala.yaml b/.manala.yaml index f4919bb74..c573a9f4e 100644 --- a/.manala.yaml +++ b/.manala.yaml @@ -18,10 +18,11 @@ project: ########## system: - dir: /srv/ansible_collections/manala/roles + dir: /usr/share/ansible/collections/ansible_collections/manala/roles env_file: - - .env.dist - .env + - path: .env.local + required: false docker: true git: config: | @@ -29,13 +30,17 @@ system: [safe] directory = * ansible: - version: 2.15.8 + version: 2.15.12 + config: | + [defaults] + force_color = True + retry_files_enabled = False dependencies: # Collection community.docker - - docker==7.0.0 + - docker==7.1.0 ansible-lint: - version: 6.14.6 + version: 24.7.0 molecule: - version: 6.0.3 + version: 24.7.0 dependencies: - molecule-plugins[docker]==23.5.3 diff --git a/.manala/Makefile b/.manala/Makefile index a9a04ef81..5dfcacf72 100644 --- a/.manala/Makefile +++ b/.manala/Makefile @@ -21,8 +21,8 @@ include $(MANALA_DIR)/.manala/docker/docker.mk ########## MANALA_DOCKER_COMPOSE_ENV += \ - MANALA_DIR=/srv/ansible_collections/manala/roles \ - MANALA_CACHE_DIR=/srv/ansible_collections/manala/roles/$(shell dir=$(MANALA_DIR)/$(MANALA_CACHE_DIR) ; mkdir -p $${dir} ; echo $(MANALA_CACHE_DIR)) + MANALA_DIR=/usr/share/ansible/collections/ansible_collections/manala/roles \ + MANALA_CACHE_DIR=/usr/share/ansible/collections/ansible_collections/manala/roles/$(shell dir=$(MANALA_DIR)/$(MANALA_CACHE_DIR) ; mkdir -p $${dir} ; echo $(MANALA_CACHE_DIR)) # Command MANALA_DOCKER_COMMAND = run --rm diff --git a/.manala/docker/Dockerfile b/.manala/docker/Dockerfile index 1ab678842..fcbc39eda 100644 --- a/.manala/docker/Dockerfile +++ b/.manala/docker/Dockerfile @@ -10,8 +10,10 @@ ARG MANALA_USER_ID="1000" ARG MANALA_GROUP_ID="1000" ARG GOSU_VERSION="1.17" -ARG GOMPLATE_VERSION="3.11.7" -ARG DIRENV_VERSION="2.33.0" +ARG GOMPLATE_VERSION="4.1.0" +ARG DIRENV_VERSION="2.34.0" +ARG JQ_VERSION="1.7.1" +ARG YQ_VERSION="4.44.3" # The 'container' environment variable tells systemd that it's running inside a # Docker container environment. @@ -19,7 +21,7 @@ ARG DIRENV_VERSION="2.33.0" ENV container="docker" # Default locale -ENV LANG C.UTF-8 +ENV LANG="C.UTF-8" SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -27,36 +29,45 @@ RUN \ apt-get --quiet update \ && apt-get --quiet --yes --purge --autoremove upgrade \ && apt-get --quiet --yes --no-install-recommends --verbose-versions install \ - s6 \ - sudo \ - curl \ - ca-certificates \ - gnupg \ - libarchive-tools bzip2 \ bash-completion \ - rsync \ + bzip2 \ + ca-certificates \ + curl \ git \ - make \ + gnupg \ less \ - vim \ + libarchive-tools \ + make \ + rsync \ + s6 \ socat \ + sudo \ + vim \ # User && addgroup --gid ${MANALA_GROUP_ID} lazy \ && adduser --home /home/lazy --shell /bin/bash --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \ && install --verbose --mode 0755 --group lazy --owner lazy --directory /run/user/${MANALA_USER_ID} \ && echo "lazy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/lazy \ # Gosu - && curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/gosu \ && chmod +x /usr/local/bin/gosu \ # Gomplate - && curl -sSL "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/gomplate \ && chmod +x /usr/local/bin/gomplate \ # Direnv - && curl -sSL "https://github.com/direnv/direnv/releases/download/v${DIRENV_VERSION}/direnv.linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/direnv/direnv/releases/download/v${DIRENV_VERSION}/direnv.linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/direnv \ && chmod +x /usr/local/bin/direnv \ + # Jq + && curl -sSLf "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/jq-linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + --output /usr/local/bin/jq \ + && chmod +x /usr/local/bin/jq \ + # Yq + && curl -sSLf "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + --output /usr/local/bin/yq \ + && chmod +x /usr/local/bin/yq \ # Bash completion && install --verbose --mode 0755 --directory /etc/bash_completion.d \ # Oh My Bash @@ -75,11 +86,11 @@ RUN \ apt-get --quiet update \ && apt-get --quiet --yes --no-install-recommends --verbose-versions install \ openssh-client \ - sshpass \ - python3 \ pipx \ + python3 \ python3-argcomplete \ shellcheck \ + sshpass \ # Sudo && echo "Defaults env_keep += \"PIPX_*\"" > /etc/sudoers.d/pipx \ # Bash completion @@ -89,7 +100,7 @@ RUN \ # Docker RUN \ - curl -sSL https://download.docker.com/linux/debian/gpg \ + curl -sSLf https://download.docker.com/linux/debian/gpg \ --output /etc/apt/keyrings/docker.asc \ && printf "\ Types: deb\n\ @@ -107,9 +118,9 @@ Signed-By: /etc/apt/keyrings/docker.asc\n\ # Ansible RUN \ pipx install --pip-args="--no-cache-dir" \ - ansible-core==2.15.8 \ + ansible-core==2.15.12 \ && pipx inject --pip-args="--no-cache-dir" ansible-core \ - docker==7.0.0 + docker==7.1.0 # Ansible Lint RUN \ @@ -120,7 +131,7 @@ RUN \ && apt-get --quiet --yes --no-install-recommends --verbose-versions install \ "${BUILD_PACKAGES[@]}" \ && pipx install --pip-args="--no-cache-dir" \ - ansible-lint==6.14.6 \ + ansible-lint==24.7.0 \ # Clean && apt-get --quiet --yes --autoremove purge \ "${BUILD_PACKAGES[@]}" \ @@ -129,7 +140,7 @@ RUN \ # Molecule RUN \ pipx install --pip-args="--no-cache-dir" \ - molecule==6.0.3 \ + molecule==24.7.0 \ && _MOLECULE_COMPLETE=bash_source molecule > /etc/bash_completion.d/molecule \ && pipx inject --pip-args="--no-cache-dir" molecule \ molecule-plugins[docker]==23.5.3 diff --git a/.manala/docker/compose.yaml b/.manala/docker/compose.yaml index 0a0cf8e0f..198a244ac 100644 --- a/.manala/docker/compose.yaml +++ b/.manala/docker/compose.yaml @@ -11,15 +11,16 @@ services: build: context: .. dockerfile: docker/Dockerfile - image: manala-ansible-roles:20240315115847 + image: manala-ansible-roles:20240916111724 volumes: - ../..:${MANALA_DIR} environment: MANALA_DIR: ${MANALA_DIR} MANALA_CACHE_DIR: ${MANALA_CACHE_DIR} env_file: - - ../../.env.dist - ../../.env + - path: ../../.env.local + required: false working_dir: ${MANALA_DIR} # Use default docker bridge network network_mode: bridge diff --git a/.manala/etc/ansible/ansible.cfg b/.manala/etc/ansible/ansible.cfg index 07bca09cf..2de201170 100644 --- a/.manala/etc/ansible/ansible.cfg +++ b/.manala/etc/ansible/ansible.cfg @@ -1,2 +1,6 @@ # Ansible config template # Don't edit this file directly. Instead, set config in project .manala.yaml, and run `manala up`. + +[defaults] +force_color = True +retry_files_enabled = False diff --git a/.manala/etc/profile.d/message.sh b/.manala/etc/profile.d/message.sh index 186fd470c..8fe5782e2 100644 --- a/.manala/etc/profile.d/message.sh +++ b/.manala/etc/profile.d/message.sh @@ -9,8 +9,8 @@ printf "\033[34m =-=-_-__=_-= _=_=-=_,-'\033[32m|\033[34m\"'\"\"-\033[32m|\033[3 printf "\033[34m =- _=-=- -_=-=_,-\" \033[32m|\033[34m\"\033[0m\n" printf "\033[34m =- =- -=.--\"\033[0m\n" printf "\n" -printf " \033[36m‣ ansible \033[35m2.15.8\033[0m\n" -printf " \033[36m· docker==7.0.0\033[0m\n" -printf " \033[36m‣ ansible-lint \033[35m6.14.6\033[0m\n" -printf " \033[36m‣ molecule \033[35m6.0.3\033[0m\n" +printf " \033[36m‣ ansible \033[35m2.15.12\033[0m\n" +printf " \033[36m· docker==7.1.0\033[0m\n" +printf " \033[36m‣ ansible-lint \033[35m24.7.0\033[0m\n" +printf " \033[36m‣ molecule \033[35m24.7.0\033[0m\n" printf " \033[36m· molecule-plugins[docker]==23.5.3\033[0m\n" diff --git a/.manala/github/system/setup/action.yaml b/.manala/github/system/setup/action.yaml index 300f82c0d..835809f1f 100644 --- a/.manala/github/system/setup/action.yaml +++ b/.manala/github/system/setup/action.yaml @@ -36,13 +36,13 @@ runs: steps: - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # Expose ACTIONS_CACHE_URL & ACTIONS_RUNTIME_TOKEN # to be consumed by docker github action cache # See: https://docs.docker.com/build/cache/backends/gha/ - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v2 + uses: crazy-max/ghaction-github-runtime@v3 - name: Set environment variables file if: inputs.docker_env != '' diff --git a/CHANGELOG.md b/CHANGELOG.md index 609eb112e..b81d371d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ -# Change Log +# Changelog + All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Fixed diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..5996085e9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Manala + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile index aadac06e8..7d3539e14 100644 --- a/Makefile +++ b/Makefile @@ -1,75 +1,102 @@ .SILENT: --include .manala/Makefile +include .manala/Makefile + +NAMESPACE = manala +COLLECTION = roles +VERSION = $(shell yq '.version' galaxy.yml) + +########### +# Version # +########### + +## Version - Get collection version +version: SHELL := $(MANALA_DOCKER_SHELL) +version: + printf $(VERSION) +.PHONY: version ######## # Lint # ######## ## Lint - Lint collection [VERBOSE] +lint: SHELL := $(MANALA_DOCKER_SHELL) lint: - $(call manala_docker_shell, ansible-lint \ + ansible-lint \ $(if $(VERBOSE), -v) \ - --force-color \ - ) + --force-color .PHONY: lint ######## # Test # ######## -## Test - Run all tests (but coverage) +## Test - Run all collection tests (but doc and coverage) test: test.sanity test.units test.integration .PHONY: test -## Test - Run sanity tests [VERBOSE] +## Test - Run collection sanity tests [VERBOSE] +test.sanity: SHELL := $(MANALA_DOCKER_SHELL) test.sanity: - $(call manala_docker_shell, ansible-test sanity \ + ansible-test sanity \ --requirements \ --venv \ --python 3.11 \ $(if $(VERBOSE), --verbose) \ --color yes \ --exclude .github/ \ - --exclude .manala/ \ - ) + --exclude .manala/ .PHONY: test.sanity -## Test - Run units tests [VERBOSE|COVERAGE] +## Test - Run collection units tests [VERBOSE|COVERAGE] +test.units: SHELL := $(MANALA_DOCKER_SHELL) test.units: - $(call manala_docker_shell, ansible-test units \ + ansible-test units \ --requirements \ --venv \ --python 3.11 \ $(if $(VERBOSE), --verbose) \ $(if $(COVERAGE), --coverage) \ - --color yes \ - ) + --color yes .PHONY: test.units -## Test - Run integration tests [VERBOSE|COVERAGE] +## Test - Run collection integration tests [VERBOSE|COVERAGE] +test.integration: SHELL := $(MANALA_DOCKER_SHELL) test.integration: - $(call manala_docker_shell, ansible-test integration \ + ansible-test integration \ --requirements \ --venv \ --python 3.11 \ $(if $(VERBOSE), --verbose) \ $(if $(COVERAGE), --coverage) \ - --color yes \ - ) + --color yes .PHONY: test.integration -## Test - Run coverage [VERBOSE] +## Test - Run collection documentation tests [VERBOSE] +test.doc: SHELL := $(MANALA_DOCKER_SHELL) +test.doc: + $(foreach type,module filter, \ + $(foreach plugin,$(shell ansible-doc --list $(NAMESPACE).$(COLLECTION) --type $(type) --json | jq --raw-output 'keys[]'), \ + ansible-doc \ + $(if $(VERBOSE), --verbose) \ + --type $(type) \ + $(plugin) > /dev/null && \ + ) \ + ) true +.PHONY: test.doc + +## Test - Run collection coverage [VERBOSE] +test.coverage: SHELL := $(MANALA_DOCKER_SHELL) test.coverage: - $(call manala_docker_shell, ansible-test coverage xml \ + ansible-test coverage xml \ --requirements \ --venv \ --python 3.11 \ --group-by command \ --group-by version \ $(if $(VERBOSE), --verbose) \ - --color yes \ - ) + --color yes .PHONY: test.coverage ############ @@ -77,38 +104,37 @@ test.coverage: ############ ## Molecule - Run molecule test [SCENARIO] +molecule.test: SHELL := $(MANALA_DOCKER_SHELL) molecule.test: - $(call manala_docker_shell, PY_COLORS=1 molecule test \ - $(if $(SCENARIO), --scenario-name $(SCENARIO), --all) \ - ) + PY_COLORS=1 molecule test \ + $(if $(SCENARIO), --scenario-name $(SCENARIO), --all) .PHONY: molecule.test ## Molecule - Rune molecule converge [SCENARIO] +molecule.converge: SHELL := $(MANALA_DOCKER_SHELL) molecule.converge: $(call manala_error_if_not, $(SCENARIO), SCENARIO has not been specified) - $(call manala_docker_shell, PY_COLORS=1 molecule converge \ - --scenario-name $(SCENARIO) \ - ) + PY_COLORS=1 molecule converge \ + --scenario-name $(SCENARIO) .PHONY: molecule.converge -############## -# Collection # -############## - -MANALA_COLLECTION = manala-roles-*.tar.gz - -define collection - $(call manala_docker_shell, ansible-galaxy collection $(1)) -endef - -## Collection - Build collection -collection.build: - rm -rf $(MANALA_COLLECTION) - $(call collection, build --force --verbose) -.PHONY: collection.build - -## Collection - Publish collection [COLLECTION_API_TOKEN] -collection.publish: - $(call manala_error_if_not, $(COLLECTION_API_TOKEN), COLLECTION_API_TOKEN has not been specified) - $(call collection, publish $(MANALA_COLLECTION) --api-key $(COLLECTION_API_TOKEN)) -.PHONY: collection.publish +################### +# Build / Publish # +################### + +## Build - Build collection [VERBOSE] +build: SHELL := $(MANALA_DOCKER_SHELL) +build: + ansible-galaxy collection build \ + --output-path build \ + --force \ + $(if $(VERBOSE), --verbose) + +.PHONY: build + +## Publish - Publish collection [VERBOSE] +publish: SHELL := $(MANALA_DOCKER_SHELL) +publish: + ansible-galaxy collection publish build/$(NAMESPACE)-$(COLLECTION)-$(VERSION).tar.gz \ + $(if $(VERBOSE), --verbose) +.PHONY: publish diff --git a/README.md b/README.md index 7abc87726..a5ac6cf8a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![homepage][image]][url] -[image]: https://www.manala.io/images/manala.svg +[image]: https://raw.githubusercontent.com/manala/resources/main/logo.svg [url]: https://www.manala.io/ "manala.io" **The flexible, robust, and web oriented toolbox for Ansible !** @@ -68,7 +68,6 @@ Any kind of contribution is very welcome, you can submit pull requests [here](ht This collection uses [molecule](https://github.com/ansible-community/molecule), [ansible-lint](https://github.com/ansible-community/ansible-lint), and `ansible-test` for linting and testing roles. -All of these tools are available through the excellent [ansible-toolset](https://github.com/ansible-community/toolset) docker image. Open a docker shell ```shell @@ -98,8 +97,8 @@ ansible-test units --python 3.11 tests/unit/plugins/lookup/test_foo.py This collection is distributed under the MIT license. -See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. +See [LICENSE](LICENSE) to see the full text. # Author information -Manala [**(http://www.manala.io/)**](http://www.manala.io) +Manala [**(https://www.manala.io/)**](https://www.manala.io/) diff --git a/galaxy.yml b/galaxy.yml index 3dfa99c1c..665af128f 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -22,10 +22,9 @@ authors: # A short summary description of the collection description: The flexible, robust, and web oriented toolbox for Ansible -# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only -# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' -license: - - MIT +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: LICENSE # A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character # requirements as 'namespace' and 'name' @@ -63,19 +62,21 @@ issues: https://github.com/manala/ansible-roles/issues # A list of file glob-like patterns used to filter any files or directories that should not be included in the build # artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This # uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', -# and '.git' are always filtered +# and '.git' are always filtered. Mutually exclusive with 'manifest' build_ignore: - .config - .github - - .env - - .env.dist - .gitignore - .DS_Store + - .vscode + - .env + - .env.local - .ansible-lint - .manala.yaml - .manala + - galaxy_token - Makefile - molecule - tests + - build - requirements.yml - - manala-roles-* diff --git a/meta/runtime.yml b/meta/runtime.yml index 6d61aff1d..f3589f4f1 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,3 +1,52 @@ --- - +# Collections must specify a minimum required ansible version to upload +# to galaxy requires_ansible: '>=2.15.0' + +# Content that Ansible needs to load from another location or that has +# been deprecated/removed +# plugin_routing: +# action: +# redirected_plugin_name: +# redirect: ns.col.new_location +# deprecated_plugin_name: +# deprecation: +# removal_version: "4.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# removed_plugin_name: +# tombstone: +# removal_version: "2.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# become: +# cache: +# callback: +# cliconf: +# connection: +# doc_fragments: +# filter: +# httpapi: +# inventory: +# lookup: +# module_utils: +# modules: +# netconf: +# shell: +# strategy: +# terminal: +# test: +# vars: + +# Python import statements that Ansible needs to load from another location +# import_redirection: +# ansible_collections.ns.col.plugins.module_utils.old_location: +# redirect: ansible_collections.ns.col.plugins.module_utils.new_location + +# Groups of actions/modules that take a common set of options +# action_groups: +# group_name: +# - module1 +# - module2 diff --git a/requirements.yml b/requirements.yml index 03f35060b..8e0605483 100644 --- a/requirements.yml +++ b/requirements.yml @@ -4,14 +4,14 @@ collections: - name: ansible.posix version: 1.5.4 - name: community.general - version: 9.1.0 + version: 9.4.0 - name: community.docker - version: 3.10.4 + version: 3.12.1 - name: community.mysql - version: 3.9.0 + version: 3.10.3 - name: community.postgresql - version: 3.4.1 + version: 3.5.0 - name: community.mongodb - version: 1.7.4 + version: 1.7.6 - name: gluster.gluster version: 1.0.2