Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Testing with ansible-core
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
fao89 committed Apr 29, 2021
1 parent 5acf908 commit 5617419
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,52 @@ jobs:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
shell: bash
core:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install Ansible
run: |
pip install --upgrade pip
sudo apt remove ansible
pip install --pre ansible-core
- name: Install Molecule
run: |
pip install molecule docker molecule-docker ansible-lint[yamllint]
MOLECULE_PATH=$(pip show molecule | grep Location | cut -d' ' -f2)
sed -i "/tasks:/i collections:" $MOLECULE_PATH/molecule_docker/playbooks/create.yml
sed -i "/collections:/a - community.docker" $MOLECULE_PATH/molecule_docker/playbooks/create.yml
sed -i "s/collections:/ collections:/g" $MOLECULE_PATH/molecule_docker/playbooks/create.yml
sed -i "s/- community.docker/ - community.docker/g" $MOLECULE_PATH/molecule_docker/playbooks/create.yml
ansible-galaxy collection install --force community.docker
- name: Install Collection
run: |
make vendor
make install
mkdir -p ~/.ansible/collections/ansible_collections/pulp/pulp_installer
cp -r ./build/collections/ansible_collections/pulp/pulp_installer/* ~/.ansible/collections/ansible_collections/pulp/pulp_installer
ansible-galaxy collection install --requirements-file requirements.yml
rm -rf ~/.ansible/collections/ansible_collections/community/general
ls -al ~/.ansible/collections/ansible_collections
ls -al ~/.ansible/collections/ansible_collections/community
- name: Adapting playbooks to use collection
run: |
sed -i "/roles:/i collections:" playbooks/example-source/playbook.yml
sed -i "/collections:/a - pulp.pulp_installer" playbooks/example-source/playbook.yml
sed -i "s/collections:/ collections:/g" playbooks/example-source/playbook.yml
sed -i "s/- pulp.pulp_installer/ - pulp.pulp_installer/g" playbooks/example-source/playbook.yml
- name: Molecule Test
run: |
ansible --version
molecule test --scenario-name source-static
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
shell: bash
vagrant:
runs-on: ubuntu-20.04
strategy:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ jobs:
- name: Install Ansible
run: pip install --upgrade ansible
- name: Build Ansible Collection
run: make dist
run: |
make vendor
make dist
- name: Deploy Ansible Collection
run: make publish GALAXY_API_KEY=${{ secrets.GALAXY_API_KEY }}

Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ MANIFEST := build/collections/ansible_collections/$(NAMESPACE)/$(NAME)/MANIFEST.

ROLES := $(wildcard roles/*)
DOCS := $(wildcard docs/*/*) $(wildcard docs/*)
PLUGINS := $(wildcard plugins/*/*) $(wildcard plugins/*)
META := $(wildcard meta/*)
PLAYBOOKS := $(wildcard playbooks/*/*/*) $(wildcard playbooks/*/*) $(wildcard playbooks/*)
METADATA := galaxy.yml COPYRIGHT LICENSE README.md requirements.yml
DEPENDENCIES := $(METADATA) $(foreach ROLE,$(ROLES),$(wildcard $(ROLE)/*/*)) $(foreach ROLE,$(ROLES),$(ROLE)/README.md) $(META) $(DOCS) $(PLAYBOOKS)
DEPENDENCIES := $(METADATA) $(foreach ROLE,$(ROLES),$(wildcard $(ROLE)/*/*)) $(foreach ROLE,$(ROLES),$(ROLE)/README.md) $(META) $(DOCS) $(PLAYBOOKS) $(PLUGINS)

MOLECULE_SCENARIO ?= release-static
TOX_ENV ?= py37-ansible2.9-$(MOLECULE_SCENARIO)
Expand Down Expand Up @@ -50,6 +51,17 @@ $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz: $(addprefix build/src/,$(DEPENDENCIES))

dist: $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz

vendor:
ansible-galaxy collection install --force community.general -p ./temp
ansible-galaxy collection install --force community.crypto -p ./temp
mkdir -p plugins/modules
cp temp/ansible_collections/community/general/plugins/modules/files/ini_file.py plugins/modules
cp temp/ansible_collections/community/general/plugins/modules/packaging/language/pip_package_info.py plugins/modules
cp temp/ansible_collections/community/general/plugins/modules/system/locale_gen.py plugins/modules
cp temp/ansible_collections/community/general/plugins/modules/system/make.py plugins/modules
cp temp/ansible_collections/community/general/plugins/modules/system/seport.py plugins/modules
rm -rf temp

install: $(MANIFEST)

publish: $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz
Expand All @@ -60,4 +72,4 @@ clean:

FORCE:

.PHONY: help dist install lint sanity test publish FORCE
.PHONY: help dist vendor install lint sanity test publish FORCE

0 comments on commit 5617419

Please sign in to comment.