Skip to content

Commit de9169e

Browse files
authored
Merge pull request #64 from stackhpc/master-workflows
feat: automatic update of workflows master
2 parents 89bd32d + 11d0fbd commit de9169e

19 files changed

+117
-121
lines changed

.ansible-lint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
skip_list:
2+
- name[missing]
3+
- var-naming[no-role-prefix]
4+
- yaml[line-length]
5+
- galaxy[no-changelog]
6+
- galaxy[version-incorrect]
7+
- meta-runtime[unsupported-version]
8+
- fqcn[action-core]

.github/workflows/lint-collection.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Ansible collection linters
3+
'on':
4+
pull_request:
5+
jobs:
6+
lint:
7+
uses: stackhpc/.github/.github/workflows/lint-collection.yml@main

.github/workflows/pull_request.yml

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,15 @@
1-
21
name: Tests
32

43
# Controls when the action will run.
5-
on:
4+
'on':
65
pull_request:
76
push:
87
branches:
98
- master
109
env:
11-
ANSIBLE_FORCE_COLOR: True
10+
ANSIBLE_FORCE_COLOR: true
1211

1312
jobs:
14-
lint:
15-
runs-on: ubuntu-latest
16-
strategy:
17-
fail-fast: false
18-
matrix:
19-
ansible:
20-
- "2.9"
21-
- "2.10"
22-
- "2.12"
23-
steps:
24-
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
25-
- uses: actions/checkout@v3
26-
27-
- uses: actions/setup-python@v4
28-
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
if [[ "${{ matrix.ansible }}" = "2.9" ]]; then
33-
ansible_package=ansible
34-
elif [[ "${{ matrix.ansible }}" = "2.10" ]]; then
35-
ansible_package=ansible-base
36-
else
37-
ansible_package=ansible-core
38-
fi
39-
pip install $ansible_package==${{ matrix.ansible }}.* 'ansible-lint==5.*'
40-
41-
- name: Install Ansible Galaxy dependencies
42-
run: |
43-
ansible-galaxy collection install pulp.squeezer
44-
45-
- name: Linting code
46-
run: |
47-
ansible-lint -v --force-color
48-
4913
integration:
5014
runs-on: ubuntu-latest
5115
strategy:

galaxy.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
namespace: "stackhpc"
2-
name: "pulp"
1+
namespace: stackhpc
2+
name: pulp
3+
description: >
4+
Roles and plugins Pulp repository server configuration
35
version: "0.5.2"
46
readme: "README.md"
57
authors:
@@ -11,6 +13,8 @@ dependencies:
1113
license:
1214
- "Apache-2.0"
1315
tags:
16+
- infrastructure
17+
- linux
1418
- pulp
1519
repository: "https://github.com/stackhpc/ansible-collection-pulp"
1620
build_ignore:

plugins/modules/pulp_container_content.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5+
46
from __future__ import absolute_import, division, print_function
57

68
__metaclass__ = type
@@ -32,12 +34,25 @@
3234
- Name of the repository to add or remove content
3335
type: str
3436
required: true
37+
state:
38+
description:
39+
- State the entity should be in
40+
type: str
41+
default: present
42+
choices:
43+
- present
44+
- absent
3545
tags:
3646
description:
3747
- List of tags to add or remove
3848
type: list
39-
items: str
49+
elements: str
4050
required: true
51+
wait:
52+
description:
53+
- Whether to wait for completion of the operation
54+
type: bool
55+
default: true
4156
extends_documentation_fragment:
4257
- pulp.squeezer.pulp
4358
- pulp.squeezer.pulp.entity_state
@@ -79,7 +94,6 @@
7994
from ansible_collections.pulp.squeezer.plugins.module_utils.pulp import (
8095
PAGE_LIMIT,
8196
PulpContainerRepository,
82-
PulpEntity,
8397
PulpEntityAnsibleModule,
8498
PulpTask,
8599
SqueezerException,
@@ -123,8 +137,8 @@ def get_content_units(self, repo):
123137
offset += PAGE_LIMIT
124138

125139
if (self.module.params["state"] == "present" and
126-
not self.module.params["allow_missing"] and
127-
len(tags) != len(self.module.params["tags"])):
140+
not self.module.params["allow_missing"] and
141+
len(tags) != len(self.module.params["tags"])):
128142
missing = ", ".join(set(self.module.params["tags"]) - set(tags))
129143
raise SqueezerException(f"Some tags not found in source repository: {missing}")
130144
return [result["pulp_href"] for result in tags]
@@ -180,8 +194,8 @@ def main():
180194
repository={"required": True},
181195
src_repo={},
182196
src_is_push={"type": "bool", "default": False},
183-
state={"default": "present"},
184-
tags={"type": "list", "item": "str", "required": True},
197+
state={"default": "present", "choices": ["present", "absent"]},
198+
tags={"type": "list", "elements": "str", "required": True},
185199
wait={"type": "bool", "default": True},
186200
),
187201
required_if=[("state", "present", ["src_repo"])],

roles/pulp_django_user/tasks/user_groups/add_user_to_groups.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

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

2424
# Will fail before we get here if the group doesn't exist or has

roles/pulp_django_user/tasks/user_groups/remove_user_from_groups.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
# from pulp API
1616
- name: Fail when group cannot be unambiguosly returned from Pulp API
1717
fail:
18-
msg: >
19-
"Pulp API query: GET '{{ group_href_result.url }}' did not return
20-
exactly one group. Groupname '{{ remove_group }}' was found
21-
'{{ group_href_result.json.count }}' times.
22-
Groupnames should be unique and exist before associating users
23-
with them"
18+
msg: >
19+
"Pulp API query: GET '{{ group_href_result.url }}' did not return
20+
exactly one group. Groupname '{{ remove_group }}' was found
21+
'{{ group_href_result.json.count }}' times.
22+
Groupnames should be unique and exist before associating users
23+
with them"
2424
when: group_href_result.json.count != 1
2525

2626
- name: Get user id from Pulp API

roles/pulp_group/tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
loop_var: "group"
2525
label: "{{ group.item.name }}"
2626
when:
27-
- group.json.count == 1
28-
- group.item.state is defined
29-
- group.item.state == "absent"
27+
- group.json.count == 1
28+
- group.item.state is defined
29+
- group.item.state == "absent"
3030

3131
- name: Set groups to create fact
3232
set_fact:
@@ -36,8 +36,8 @@
3636
loop_var: "group"
3737
label: "{{ group.item.name }}"
3838
when:
39-
- group.json.count == 0
40-
- group.item.state is not defined or group.item.state != "absent"
39+
- group.json.count == 0
40+
- group.item.state is not defined or group.item.state != "absent"
4141

4242
- name: Create groups
4343
uri:

roles/pulp_repository/tasks/container.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
url: "{{ pulp_repository_container_repos[repository_index].url | default(omit) }}"
3636
state: "{{ pulp_repository_container_repos[repository_index].state }}"
3737
when: >
38-
pulp_repository_container_repos[repository_index].state == "absent" or
38+
pulp_repository_container_repos[repository_index].state == "absent" or
3939
pulp_repository_container_repos[repository_index].url is defined
4040
loop: "{{ pulp_repository_container_repos | map(attribute='name') }}"
4141
loop_control:
@@ -56,6 +56,6 @@
5656
loop_control:
5757
index_var: repository_index
5858
register: pulp_repository_container_repos_sync
59-
until: "pulp_repository_container_repos_sync is not failed"
59+
until: "pulp_repository_container_repos_sync is not failed"
6060
retries: "{{ pulp_repository_container_repos_sync_retries }}"
6161
delay: 1

roles/pulp_repository/tasks/deb.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
url: "{{ pulp_repository_deb_repos[repository_index].url | default(omit) }}"
3636
state: "{{ pulp_repository_deb_repos[repository_index].state }}"
3737
when: >
38-
pulp_repository_deb_repos[repository_index].state == "absent" or
38+
pulp_repository_deb_repos[repository_index].state == "absent" or
3939
pulp_repository_deb_repos[repository_index].url is defined
4040
loop: "{{ pulp_repository_deb_repos | map(attribute='name') }}"
4141
loop_control:
@@ -57,6 +57,6 @@
5757
loop_control:
5858
index_var: repository_index
5959
register: pulp_repository_deb_repos_sync
60-
until: "pulp_repository_deb_repos_sync is not failed"
60+
until: "pulp_repository_deb_repos_sync is not failed"
6161
retries: "{{ pulp_repository_deb_repos_sync_retries }}"
6262
delay: 1

roles/pulp_repository/tasks/python.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
url: "{{ pulp_repository_python_repos[repository_index].url | default(omit) }}"
3636
state: "{{ pulp_repository_python_repos[repository_index].state }}"
3737
when: >
38-
pulp_repository_python_repos[repository_index].state == "absent" or
38+
pulp_repository_python_repos[repository_index].state == "absent" or
3939
pulp_repository_python_repos[repository_index].url is defined
4040
loop: "{{ pulp_repository_python_repos | map(attribute='name') }}"
4141
loop_control:
@@ -56,7 +56,6 @@
5656
loop_control:
5757
index_var: repository_index
5858
register: pulp_repository_python_repos_sync
59-
until: "pulp_repository_python_repos_sync is not failed"
59+
until: "pulp_repository_python_repos_sync is not failed"
6060
retries: "{{ pulp_repository_python_repos_sync_retries }}"
6161
delay: 1
62-

roles/pulp_repository/tasks/rpm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
url: "{{ pulp_repository_rpm_repos[repository_index].url | default(omit) }}"
3333
state: "{{ pulp_repository_rpm_repos[repository_index].state }}"
3434
when: >
35-
pulp_repository_rpm_repos[repository_index].state == "absent" or
35+
pulp_repository_rpm_repos[repository_index].state == "absent" or
3636
pulp_repository_rpm_repos[repository_index].url is defined
3737
loop: "{{ pulp_repository_rpm_repos | map(attribute='name') }}"
3838
loop_control:
@@ -54,6 +54,6 @@
5454
loop_control:
5555
index_var: repository_index
5656
register: pulp_repository_rpm_repos_sync
57-
until: "pulp_repository_rpm_repos_sync is not failed"
57+
until: "pulp_repository_rpm_repos_sync is not failed"
5858
retries: "{{ pulp_repository_rpm_repos_sync_retries }}"
5959
delay: 1

tests/pulp-in-one.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -eu
22

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

2828
# Wait for it to come up.
2929
attempts=0

tests/test_container_content.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
method: GET
5050
status_code: 200
5151
force_basic_auth: true
52-
register: tags
52+
register: container_tags
5353

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

5959
# Test idempotence and not waiting
6060
- include_role:
@@ -96,12 +96,12 @@
9696
method: GET
9797
status_code: 200
9898
force_basic_auth: true
99-
register: tags
99+
register: container_tags
100100

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

106106
# Test idempotence
107107
- include_role:
@@ -141,12 +141,12 @@
141141
method: GET
142142
status_code: 200
143143
force_basic_auth: true
144-
register: tags
144+
register: container_tags
145145

146146
- name: Assert that all tags have been removed
147147
assert:
148148
that:
149-
- tags.json.results == []
149+
- container_tags.json.results == []
150150

151151
- include_role:
152152
name: pulp_container_content

tests/test_container_repository.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@
8282
that: container_remotes.remotes | length == 0
8383

8484
- block:
85-
- include_role:
86-
name: pulp_repository
87-
vars:
88-
pulp_repository_container_repos:
89-
- name: test_container_repo_bad_url
90-
upstream_name: pulp/test-fixture-1
91-
url: "https://google.com/404"
92-
policy: immediate
93-
state: present
85+
- include_role:
86+
name: pulp_repository
87+
vars:
88+
pulp_repository_container_repos:
89+
- name: test_container_repo_bad_url
90+
upstream_name: pulp/test-fixture-1
91+
url: "https://google.com/404"
92+
policy: immediate
93+
state: present
9494

9595
rescue:
9696
- set_fact:
@@ -111,5 +111,5 @@
111111
name: pulp_repository
112112
vars:
113113
pulp_repository_deb_repos:
114-
- name: test_container_repo_bad_url
115-
state: absent
114+
- name: test_container_repo_bad_url
115+
state: absent

tests/test_content_guard_rbac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
assert:
152152
that:
153153
- rbac_cg_list.json.results | json_query(query) | length == 0
154-
154+
155155
- name: Cleanup
156156
include_role:
157157
name: pulp_content_guard

0 commit comments

Comments
 (0)