Skip to content

feat: automatic update of workflows master #64

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

Merged
merged 9 commits into from
Aug 3, 2023
Merged
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
8 changes: 8 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
skip_list:
- name[missing]
- var-naming[no-role-prefix]
- yaml[line-length]
- galaxy[no-changelog]
- galaxy[version-incorrect]
- meta-runtime[unsupported-version]
- fqcn[action-core]
7 changes: 7 additions & 0 deletions .github/workflows/lint-collection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Ansible collection linters
'on':
pull_request:
jobs:
lint:
uses: stackhpc/.github/.github/workflows/lint-collection.yml@main
40 changes: 2 additions & 38 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,15 @@

name: Tests

# Controls when the action will run.
on:
'on':
pull_request:
push:
branches:
- master
env:
ANSIBLE_FORCE_COLOR: True
ANSIBLE_FORCE_COLOR: true

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible:
- "2.9"
- "2.10"
- "2.12"
steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
- uses: actions/checkout@v3

- uses: actions/setup-python@v4

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.ansible }}" = "2.9" ]]; then
ansible_package=ansible
elif [[ "${{ matrix.ansible }}" = "2.10" ]]; then
ansible_package=ansible-base
else
ansible_package=ansible-core
fi
pip install $ansible_package==${{ matrix.ansible }}.* 'ansible-lint==5.*'

- name: Install Ansible Galaxy dependencies
run: |
ansible-galaxy collection install pulp.squeezer

- name: Linting code
run: |
ansible-lint -v --force-color

integration:
runs-on: ubuntu-latest
strategy:
Expand Down
8 changes: 6 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace: "stackhpc"
name: "pulp"
namespace: stackhpc
name: pulp
description: >
Roles and plugins Pulp repository server configuration
version: "0.5.2"
readme: "README.md"
authors:
Expand All @@ -11,6 +13,8 @@ dependencies:
license:
- "Apache-2.0"
tags:
- infrastructure
- linux
- pulp
repository: "https://github.com/stackhpc/ansible-collection-pulp"
build_ignore:
Expand Down
26 changes: 20 additions & 6 deletions plugins/modules/pulp_container_content.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -32,12 +34,25 @@
- Name of the repository to add or remove content
type: str
required: true
state:
description:
- State the entity should be in
type: str
default: present
choices:
- present
- absent
tags:
description:
- List of tags to add or remove
type: list
items: str
elements: str
required: true
wait:
description:
- Whether to wait for completion of the operation
type: bool
default: true
extends_documentation_fragment:
- pulp.squeezer.pulp
- pulp.squeezer.pulp.entity_state
Expand Down Expand Up @@ -79,7 +94,6 @@
from ansible_collections.pulp.squeezer.plugins.module_utils.pulp import (
PAGE_LIMIT,
PulpContainerRepository,
PulpEntity,
PulpEntityAnsibleModule,
PulpTask,
SqueezerException,
Expand Down Expand Up @@ -123,8 +137,8 @@ def get_content_units(self, repo):
offset += PAGE_LIMIT

if (self.module.params["state"] == "present" and
not self.module.params["allow_missing"] and
len(tags) != len(self.module.params["tags"])):
not self.module.params["allow_missing"] and
len(tags) != len(self.module.params["tags"])):
missing = ", ".join(set(self.module.params["tags"]) - set(tags))
raise SqueezerException(f"Some tags not found in source repository: {missing}")
return [result["pulp_href"] for result in tags]
Expand Down Expand Up @@ -180,8 +194,8 @@ def main():
repository={"required": True},
src_repo={},
src_is_push={"type": "bool", "default": False},
state={"default": "present"},
tags={"type": "list", "item": "str", "required": True},
state={"default": "present", "choices": ["present", "absent"]},
tags={"type": "list", "elements": "str", "required": True},
wait={"type": "bool", "default": True},
),
required_if=[("state", "present", ["src_repo"])],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

- name: Fail when group cannot be unambiguosly returned from Pulp
fail:
msg: >
"Pulp API query: GET '{{ group_href_result.url }}' did not return
exactly one group. Groupname '{{ add_group }}' was found
'{{ group_href_result.json.count }}' times.
Groupnames should be unique and exist before associating users
with them"
msg: >
"Pulp API query: GET '{{ group_href_result.url }}' did not return
exactly one group. Groupname '{{ add_group }}' was found
'{{ group_href_result.json.count }}' times.
Groupnames should be unique and exist before associating users
with them"
when: group_href_result.json.count != 1

# Will fail before we get here if the group doesn't exist or has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# from pulp API
- name: Fail when group cannot be unambiguosly returned from Pulp API
fail:
msg: >
"Pulp API query: GET '{{ group_href_result.url }}' did not return
exactly one group. Groupname '{{ remove_group }}' was found
'{{ group_href_result.json.count }}' times.
Groupnames should be unique and exist before associating users
with them"
msg: >
"Pulp API query: GET '{{ group_href_result.url }}' did not return
exactly one group. Groupname '{{ remove_group }}' was found
'{{ group_href_result.json.count }}' times.
Groupnames should be unique and exist before associating users
with them"
when: group_href_result.json.count != 1

- name: Get user id from Pulp API
Expand Down
10 changes: 5 additions & 5 deletions roles/pulp_group/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
loop_var: "group"
label: "{{ group.item.name }}"
when:
- group.json.count == 1
- group.item.state is defined
- group.item.state == "absent"
- group.json.count == 1
- group.item.state is defined
- group.item.state == "absent"

- name: Set groups to create fact
set_fact:
Expand All @@ -36,8 +36,8 @@
loop_var: "group"
label: "{{ group.item.name }}"
when:
- group.json.count == 0
- group.item.state is not defined or group.item.state != "absent"
- group.json.count == 0
- group.item.state is not defined or group.item.state != "absent"

- name: Create groups
uri:
Expand Down
4 changes: 2 additions & 2 deletions roles/pulp_repository/tasks/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
url: "{{ pulp_repository_container_repos[repository_index].url | default(omit) }}"
state: "{{ pulp_repository_container_repos[repository_index].state }}"
when: >
pulp_repository_container_repos[repository_index].state == "absent" or
pulp_repository_container_repos[repository_index].state == "absent" or
pulp_repository_container_repos[repository_index].url is defined
loop: "{{ pulp_repository_container_repos | map(attribute='name') }}"
loop_control:
Expand All @@ -56,6 +56,6 @@
loop_control:
index_var: repository_index
register: pulp_repository_container_repos_sync
until: "pulp_repository_container_repos_sync is not failed"
until: "pulp_repository_container_repos_sync is not failed"
retries: "{{ pulp_repository_container_repos_sync_retries }}"
delay: 1
4 changes: 2 additions & 2 deletions roles/pulp_repository/tasks/deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
url: "{{ pulp_repository_deb_repos[repository_index].url | default(omit) }}"
state: "{{ pulp_repository_deb_repos[repository_index].state }}"
when: >
pulp_repository_deb_repos[repository_index].state == "absent" or
pulp_repository_deb_repos[repository_index].state == "absent" or
pulp_repository_deb_repos[repository_index].url is defined
loop: "{{ pulp_repository_deb_repos | map(attribute='name') }}"
loop_control:
Expand All @@ -57,6 +57,6 @@
loop_control:
index_var: repository_index
register: pulp_repository_deb_repos_sync
until: "pulp_repository_deb_repos_sync is not failed"
until: "pulp_repository_deb_repos_sync is not failed"
retries: "{{ pulp_repository_deb_repos_sync_retries }}"
delay: 1
5 changes: 2 additions & 3 deletions roles/pulp_repository/tasks/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
url: "{{ pulp_repository_python_repos[repository_index].url | default(omit) }}"
state: "{{ pulp_repository_python_repos[repository_index].state }}"
when: >
pulp_repository_python_repos[repository_index].state == "absent" or
pulp_repository_python_repos[repository_index].state == "absent" or
pulp_repository_python_repos[repository_index].url is defined
loop: "{{ pulp_repository_python_repos | map(attribute='name') }}"
loop_control:
Expand All @@ -56,7 +56,6 @@
loop_control:
index_var: repository_index
register: pulp_repository_python_repos_sync
until: "pulp_repository_python_repos_sync is not failed"
until: "pulp_repository_python_repos_sync is not failed"
retries: "{{ pulp_repository_python_repos_sync_retries }}"
delay: 1

4 changes: 2 additions & 2 deletions roles/pulp_repository/tasks/rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
url: "{{ pulp_repository_rpm_repos[repository_index].url | default(omit) }}"
state: "{{ pulp_repository_rpm_repos[repository_index].state }}"
when: >
pulp_repository_rpm_repos[repository_index].state == "absent" or
pulp_repository_rpm_repos[repository_index].state == "absent" or
pulp_repository_rpm_repos[repository_index].url is defined
loop: "{{ pulp_repository_rpm_repos | map(attribute='name') }}"
loop_control:
Expand All @@ -54,6 +54,6 @@
loop_control:
index_var: repository_index
register: pulp_repository_rpm_repos_sync
until: "pulp_repository_rpm_repos_sync is not failed"
until: "pulp_repository_rpm_repos_sync is not failed"
retries: "{{ pulp_repository_rpm_repos_sync_retries }}"
delay: 1
4 changes: 2 additions & 2 deletions tests/pulp-in-one.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -eu

# Run a Pulp in one container, and reset the admin password to 'password'.
# Use only for testing!
Expand All @@ -23,7 +23,7 @@ docker run \
--name pulp \
--volume "$(pwd)/settings":/etc/pulp \
--publish 8080:80 \
pulp/pulp:$PULP_TAG
pulp/pulp:"$PULP_TAG"

# Wait for it to come up.
attempts=0
Expand Down
12 changes: 6 additions & 6 deletions tests/test_container_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
method: GET
status_code: 200
force_basic_auth: true
register: tags
register: container_tags

- name: Assert that tags have been added
assert:
that:
- tags.json.results | map(attribute='name') | sort | list == ['manifest_a', 'manifest_b']
- container_tags.json.results | map(attribute='name') | sort | list == ['manifest_a', 'manifest_b']

# Test idempotence and not waiting
- include_role:
Expand Down Expand Up @@ -96,12 +96,12 @@
method: GET
status_code: 200
force_basic_auth: true
register: tags
register: container_tags

- name: Assert that manifest_b tag has been removed
assert:
that:
- tags.json.results | map(attribute='name') | list == ['manifest_a']
- container_tags.json.results | map(attribute='name') | list == ['manifest_a']

# Test idempotence
- include_role:
Expand Down Expand Up @@ -141,12 +141,12 @@
method: GET
status_code: 200
force_basic_auth: true
register: tags
register: container_tags

- name: Assert that all tags have been removed
assert:
that:
- tags.json.results == []
- container_tags.json.results == []

- include_role:
name: pulp_container_content
Expand Down
22 changes: 11 additions & 11 deletions tests/test_container_repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@
that: container_remotes.remotes | length == 0

- block:
- include_role:
name: pulp_repository
vars:
pulp_repository_container_repos:
- name: test_container_repo_bad_url
upstream_name: pulp/test-fixture-1
url: "https://google.com/404"
policy: immediate
state: present
- include_role:
name: pulp_repository
vars:
pulp_repository_container_repos:
- name: test_container_repo_bad_url
upstream_name: pulp/test-fixture-1
url: "https://google.com/404"
policy: immediate
state: present

rescue:
- set_fact:
Expand All @@ -111,5 +111,5 @@
name: pulp_repository
vars:
pulp_repository_deb_repos:
- name: test_container_repo_bad_url
state: absent
- name: test_container_repo_bad_url
state: absent
2 changes: 1 addition & 1 deletion tests/test_content_guard_rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
assert:
that:
- rbac_cg_list.json.results | json_query(query) | length == 0

- name: Cleanup
include_role:
name: pulp_content_guard
Expand Down
Loading