Compare commits

..

16 Commits
6.6.1 ... 6.6.2

Author SHA1 Message Date
Felix Fontein
a3c711491a Release 6.6.2. 2023-06-19 19:29:50 +02:00
Felix Fontein
d6a57882d2 Prepare 6.6.2 release. 2023-06-19 19:12:11 +02:00
patchback[bot]
edbef2266d [PR #6735/9642be8b backport][stable-6] Update Datadog downtime URL (#6737)
Update Datadog downtime URL (#6735)

(cherry picked from commit 9642be8b19)

Co-authored-by: Pedro Dias <61794382+diasp-ppb@users.noreply.github.com>
2023-06-19 18:40:42 +02:00
patchback[bot]
2b88ee01d3 [PR #6575/f710a10f backport][stable-6] ini_file: try using inactive option before creating a new one (#6728)
ini_file: try using inactive option before creating a new one (#6575)

* ini_file: make inactive options as active if they exist, instead of creating a new option entry

Add changelog fragment

* Update changelogs/fragments/ini_file-use-inactive-options-when-possible.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fix test

* Update tests

* Fix spelling

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f710a10f25)

Co-authored-by: njutn95 <njutn95@yahoo.com>
2023-06-19 08:01:18 +02:00
patchback[bot]
afd24ccd35 [PR #6712/e85b0080 backport][stable-6] gitlab_group => Make most options optional (#6724)
gitlab_group => Make most options optional (#6712)

* Make most options optional as they should be

* Add filter to create_group instead

* Remove whitespace

* Add changelog fragment

* Added description and extension to fragment

* Update changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/gitlab_group.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Make Python 2.6 compatible.

* Another shot at compatibility.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e85b008036)

Co-authored-by: Intellium <w.moeken@moeken.eu>
2023-06-18 21:27:29 +02:00
Felix Fontein
26ada26df1 ansible-core devel no longer supports the Ubuntu 20.04 VM.
(cherry picked from commit 3b13c30112)
2023-06-16 06:18:10 +02:00
patchback[bot]
59999a89f1 [PR #6662/bb216934 backport][stable-6] csv module utils: detect unicode BOM in content (#6694)
csv module utils: detect unicode BOM in content (#6662)

* csv module utils: detect unicode BOM in content

* fix handling of py2

* fix comment

* add changelog frag

* add missing link

* simplification

(cherry picked from commit bb2169340d)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2023-06-15 08:13:24 +02:00
patchback[bot]
e1f4be1e01 [PR #6688/032996e0 backport][stable-6] Fix composites comparison for role in is_struct_included keycloak.py … (#6689)
Fix composites comparison for role in is_struct_included keycloak.py … (#6688)

* Fix composites comparison for role in is_struct_included keycloak.py function

* Add changelog fragment and unit tests

* Update changelogs/fragments/6688-is-struct-included-bug-in-keycloak-py.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 032996e005)

Co-authored-by: Philippe Gauthier <philippe.gauthier@inspq.qc.ca>
2023-06-14 23:30:30 +02:00
patchback[bot]
e7e2f095ee [PR #6629/2cfbcb4e backport][stable-6] CI: ansible-core devel drops support for Python 3.5 (#6633)
CI: ansible-core devel drops support for Python 3.5 (#6629)

ansible-core devel drops support for Python 3.5.

(cherry picked from commit 2cfbcb4efd)

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-06-07 06:59:41 +02:00
patchback[bot]
45200fc233 [PR #6620/91b69263 backport][stable-6] Fixed typo in record_values documentation (#6625)
Fixed typo in record_values documentation (#6620)

(cherry picked from commit 91b692634e)

Co-authored-by: Tristan Pinaudeau <tristan@tic.sh>
2023-06-06 07:39:13 +02:00
patchback[bot]
154d1b7024 [PR #6613/36e8653c backport][stable-6] Minor bitwarden plugin req. docs addition (#6622)
Minor bitwarden plugin req. docs addition (#6613)

The Bitwarden CLI requires a `login` followed by an `unlock` operation.
The later will display a message regarding setting (and exporting) the
`$BW_SESSION` env. var. When using the `bitwarden` lookup plugin, having
the env. var. set and available (exported) to Ansible is critical.
Without it, the plugin will simply return the error:

`Bitwarden Vault locked. Run 'bw unlock'.`

Make this clearer in the requirement documentation.

Signed-off-by: Chris Evich <cevich@redhat.com>
(cherry picked from commit 36e8653cf7)

Co-authored-by: Chris Evich <1183438+cevich@users.noreply.github.com>
2023-06-06 06:04:51 +02:00
patchback[bot]
541fcec900 [PR #6603/47f39675 backport][stable-6] Update BOTMETA.yml (#6606)
Update BOTMETA.yml (#6603)

Stepping down from maintaining parted module

(cherry picked from commit 47f39675a9)

Co-authored-by: Robert Osowiecki <robert.osowiecki@gmail.com>
2023-05-30 22:19:33 +02:00
patchback[bot]
dc6ccbea63 [PR #6584/a6dd7d78 backport][stable-6] Move ansible-core 2.12 to EOL CI (#6586)
Move ansible-core 2.12 to EOL CI (#6584)

* https://github.com/ansible/ansible/pull/79734 has been merged and backported for all branches but stable-2.10 and stable-2.11.

* Move ansible-core 2.12 to EOL CI.

(cherry picked from commit a6dd7d789b)

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-05-29 18:39:15 +02:00
patchback[bot]
6cb044ac13 [PR #6568/27fe14bf backport][stable-6] Fix get_user_by_username in keycloak library (#6582)
Fix get_user_by_username in keycloak library (#6568)

* Fix get_user_by_username in keycloak library for keycloak_user_rolemapping module

* Add changelog fragment for keycloak.py bug fix

(cherry picked from commit 27fe14bfc1)

Co-authored-by: Philippe Gauthier <philippe.gauthier@inspq.qc.ca>
2023-05-29 15:58:56 +02:00
patchback[bot]
af78b2068a [PR #6578/ab046755 backport][stable-6] CI: restrict to python-nomad < 2.0.0 for Python < 3.7 (#6580)
CI: restrict to python-nomad < 2.0.0 for Python < 3.7 (#6578)

Restrict to python-nomad < 2.0.0 for Python < 3.7.

(cherry picked from commit ab046755bb)

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-05-29 15:58:44 +02:00
Felix Fontein
73569b1c36 Next expected release is 6.6.2. 2023-05-22 22:33:13 +02:00
18 changed files with 292 additions and 125 deletions

View File

@@ -112,19 +112,6 @@ stages:
- test: 2
- test: 3
- test: 4
- stage: Sanity_2_12
displayName: Sanity 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: Test {0}
testFormat: 2.12/sanity/{0}
targets:
- test: 1
- test: 2
- test: 3
- test: 4
### Units
- stage: Units_devel
displayName: Units devel
@@ -136,7 +123,6 @@ stages:
testFormat: devel/units/{0}/1
targets:
- test: 2.7
- test: 3.5
- test: 3.6
- test: 3.7
- test: 3.8
@@ -152,6 +138,7 @@ stages:
nameFormat: Python {0}
testFormat: 2.15/units/{0}/1
targets:
- test: 3.5
- test: "3.10"
- stage: Units_2_14
displayName: Units 2.14
@@ -174,17 +161,6 @@ stages:
targets:
- test: 2.7
- test: 3.8
- stage: Units_2_12
displayName: Units 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: Python {0}
testFormat: 2.12/units/{0}/1
targets:
- test: 2.6
- test: 3.8
## Remote
- stage: Remote_devel_extra_vms
@@ -199,8 +175,6 @@ stages:
test: alpine/3.17
# - name: Fedora 37
# test: fedora/37
# - name: Ubuntu 20.04
# test: ubuntu/20.04
- name: Ubuntu 22.04
test: ubuntu/22.04
groups:
@@ -269,22 +243,6 @@ stages:
test: macos/12.0
- name: RHEL 8.5
test: rhel/8.5
groups:
- 1
- 2
- 3
- stage: Remote_2_12
displayName: Remote 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.12/{0}
targets:
- name: macOS 11.1
test: macos/11.1
- name: RHEL 8.4
test: rhel/8.4
- name: FreeBSD 13.0
test: freebsd/13.0
groups:
@@ -361,24 +319,6 @@ stages:
- 1
- 2
- 3
- stage: Docker_2_12
displayName: Docker 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.12/linux/{0}
targets:
- name: CentOS 6
test: centos6
- name: Fedora 34
test: fedora34
- name: Ubuntu 18.04
test: ubuntu1804
groups:
- 1
- 2
- 3
### Community Docker
- stage: Docker_community_devel
@@ -442,45 +382,30 @@ stages:
testFormat: 2.13/generic/{0}/1
targets:
- test: 3.9
- stage: Generic_2_12
displayName: Generic 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: Python {0}
testFormat: 2.12/generic/{0}/1
targets:
- test: 3.8
- stage: Summary
condition: succeededOrFailed()
dependsOn:
- Sanity_devel
- Sanity_2_12
- Sanity_2_13
- Sanity_2_14
- Sanity_2_15
- Units_devel
- Units_2_12
- Units_2_13
- Units_2_14
- Units_2_15
- Remote_devel_extra_vms
- Remote_devel
- Remote_2_12
- Remote_2_13
- Remote_2_14
- Remote_2_15
- Docker_devel
- Docker_2_12
- Docker_2_13
- Docker_2_14
- Docker_2_15
- Docker_community_devel
# Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled.
# - Generic_devel
# - Generic_2_12
# - Generic_2_13
# - Generic_2_14
# - Generic_2_15

2
.github/BOTMETA.yml vendored
View File

@@ -929,7 +929,7 @@ files:
$modules/pamd.py:
maintainers: kevensen
$modules/parted.py:
maintainers: ColOfAbRiX rosowiecki jake2184
maintainers: ColOfAbRiX jake2184
$modules/pear.py:
ignore: jle64
labels: pear

View File

@@ -30,6 +30,7 @@ jobs:
matrix:
ansible:
- '2.11'
- '2.12'
# Ansible-test on various stable branches does not yet work well with cgroups v2.
# Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04
# image for these stable branches. The list of branches where this is necessary will
@@ -43,7 +44,7 @@ jobs:
- name: Perform sanity testing
uses: felixfontein/ansible-test-gh-action@main
with:
ansible-core-github-repository-slug: felixfontein/ansible
ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }}
ansible-core-version: stable-${{ matrix.ansible }}
coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }}
pull-request-change-detection: 'true'
@@ -75,6 +76,10 @@ jobs:
python: '2.7'
- ansible: '2.11'
python: '3.5'
- ansible: '2.12'
python: '2.6'
- ansible: '2.12'
python: '3.8'
steps:
- name: >-
@@ -82,7 +87,7 @@ jobs:
Ansible version ${{ matrix.ansible }}
uses: felixfontein/ansible-test-gh-action@main
with:
ansible-core-github-repository-slug: felixfontein/ansible
ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }}
ansible-core-version: stable-${{ matrix.ansible }}
coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }}
pre-test-cmd: >-
@@ -163,7 +168,49 @@ jobs:
# - ansible: '2.11'
# docker: default
# python: '3.5'
# target: azp/generic/2/
# target: azp/generic/1/
# 2.12
- ansible: '2.12'
docker: centos6
python: ''
target: azp/posix/1/
- ansible: '2.12'
docker: centos6
python: ''
target: azp/posix/2/
- ansible: '2.12'
docker: centos6
python: ''
target: azp/posix/3/
- ansible: '2.12'
docker: fedora34
python: ''
target: azp/posix/1/
- ansible: '2.12'
docker: fedora34
python: ''
target: azp/posix/2/
- ansible: '2.12'
docker: fedora34
python: ''
target: azp/posix/3/
- ansible: '2.12'
docker: ubuntu1804
python: ''
target: azp/posix/1/
- ansible: '2.12'
docker: ubuntu1804
python: ''
target: azp/posix/2/
- ansible: '2.12'
docker: ubuntu1804
python: ''
target: azp/posix/3/
# Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled.
# - ansible: '2.12'
# docker: default
# python: '3.8'
# target: azp/generic/1/
steps:
- name: >-
@@ -172,7 +219,7 @@ jobs:
under Python ${{ matrix.python }}
uses: felixfontein/ansible-test-gh-action@main
with:
ansible-core-github-repository-slug: felixfontein/ansible
ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }}
ansible-core-version: stable-${{ matrix.ansible }}
coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }}
docker-image: ${{ matrix.docker }}

View File

@@ -6,6 +6,23 @@ Community General Release Notes
This changelog describes changes after version 5.0.0.
v6.6.2
======
Release Summary
---------------
Regular bugfix release.
Bugfixes
--------
- csv module utils - detects and remove unicode BOM markers from incoming CSV content (https://github.com/ansible-collections/community.general/pull/6662).
- gitlab_group - the module passed parameters to the API call even when not set. The module is now filtering out ``None`` values to remediate this (https://github.com/ansible-collections/community.general/pull/6712).
- ini_file - fix a bug where the inactive options were not used when possible (https://github.com/ansible-collections/community.general/pull/6575).
- keycloak module utils - fix ``is_struct_included`` handling of lists of lists/dictionaries (https://github.com/ansible-collections/community.general/pull/6688).
- keycloak module utils - the function ``get_user_by_username`` now return the user representation or ``None`` as stated in the documentation (https://github.com/ansible-collections/community.general/pull/6758).
v6.6.1
======

View File

@@ -1402,3 +1402,25 @@ releases:
- deps.yml
- passwordstore-lock.yml
release_date: '2023-05-22'
6.6.2:
changes:
bugfixes:
- csv module utils - detects and remove unicode BOM markers from incoming CSV
content (https://github.com/ansible-collections/community.general/pull/6662).
- gitlab_group - the module passed parameters to the API call even when not
set. The module is now filtering out ``None`` values to remediate this (https://github.com/ansible-collections/community.general/pull/6712).
- ini_file - fix a bug where the inactive options were not used when possible
(https://github.com/ansible-collections/community.general/pull/6575).
- keycloak module utils - fix ``is_struct_included`` handling of lists of lists/dictionaries
(https://github.com/ansible-collections/community.general/pull/6688).
- keycloak module utils - the function ``get_user_by_username`` now return the
user representation or ``None`` as stated in the documentation (https://github.com/ansible-collections/community.general/pull/6758).
release_summary: Regular bugfix release.
fragments:
- 6.6.2.yml
- 6568-fix-get-user-by-username-in-keycloak-module-utils.yml
- 6662-csv-bom.yml
- 6688-is-struct-included-bug-in-keycloak-py.yml
- 6712-gitlab_group-filtered-for-none-values.yml
- ini_file-use-inactive-options-when-possible.yml
release_date: '2023-06-19'

View File

@@ -5,7 +5,7 @@
namespace: community
name: general
version: 6.6.1
version: 6.6.2
readme: README.md
authors:
- Ansible (https://github.com/ansible)

View File

@@ -12,6 +12,8 @@ DOCUMENTATION = """
requirements:
- bw (command line utility)
- be logged into bitwarden
- bitwarden vault unlocked
- C(BW_SESSION) environment variable set
short_description: Retrieve secrets from Bitwarden
version_added: 5.4.0
description:

View File

@@ -55,8 +55,10 @@ def initialize_dialect(dialect, **kwargs):
def read_csv(data, dialect, fieldnames=None):
BOM = to_native(u'\ufeff')
data = to_native(data, errors='surrogate_or_strict')
if data.startswith(BOM):
data = data[len(BOM):]
if PY3:
fake_fh = StringIO(data)

View File

@@ -207,24 +207,30 @@ def is_struct_included(struct1, struct2, exclude=None):
Return True if all element of dict 1 are present in dict 2, return false otherwise.
"""
if isinstance(struct1, list) and isinstance(struct2, list):
if not struct1 and not struct2:
return True
for item1 in struct1:
if isinstance(item1, (list, dict)):
for item2 in struct2:
if not is_struct_included(item1, item2, exclude):
return False
if is_struct_included(item1, item2, exclude):
break
else:
return False
else:
if item1 not in struct2:
return False
return True
elif isinstance(struct1, dict) and isinstance(struct2, dict):
if not struct1 and not struct2:
return True
try:
for key in struct1:
if not (exclude and key in exclude):
if not is_struct_included(struct1[key], struct2[key], exclude):
return False
return True
except KeyError:
return False
return True
elif isinstance(struct1, bool) and isinstance(struct2, bool):
return struct1 == struct2
else:
@@ -747,8 +753,15 @@ class KeycloakAPI(object):
users_url = URL_USERS.format(url=self.baseurl, realm=realm)
users_url += '?username=%s&exact=true' % username
try:
return json.loads(to_native(open_url(users_url, method='GET', headers=self.restheaders, timeout=self.connection_timeout,
validate_certs=self.validate_certs).read()))
userrep = None
users = json.loads(to_native(open_url(users_url, method='GET', headers=self.restheaders, timeout=self.connection_timeout,
validate_certs=self.validate_certs).read()))
for user in users:
if user['username'] == username:
userrep = user
break
return userrep
except ValueError as e:
self.module.fail_json(msg='API returned incorrect JSON when trying to obtain the user for realm %s and username %s: %s'
% (realm, username, str(e)))

View File

@@ -16,7 +16,7 @@ short_description: Manages Datadog downtimes
version_added: 2.0.0
description:
- Manages downtimes within Datadog.
- Options as described on U(https://docs.datadoghq.com/api/v1/downtimes/s).
- Options as described on U(https://docs.datadoghq.com/api/v1/downtimes/).
author:
- Datadog (@Datadog)
requirements:

View File

@@ -255,7 +255,10 @@ class GitLabGroup(object):
return True
try:
group = self._gitlab.groups.create(arguments)
# Filter out None values
filtered = dict((arg_key, arg_value) for arg_key, arg_value in arguments.items() if arg_value is not None)
group = self._gitlab.groups.create(filtered)
except (gitlab.exceptions.GitlabCreateError) as e:
self._module.fail_json(msg="Failed to create group: %s " % to_native(e))

View File

@@ -316,14 +316,14 @@ def do_ini(module, filename, section=None, option=None, values=None,
# override option with no value to option with value if not allow_no_value
if len(values) > 0:
for index, line in enumerate(section_lines):
if not changed_lines[index] and match_active_opt(option, line):
if not changed_lines[index] and match_opt(option, line):
newline = assignment_format % (option, values.pop(0))
(changed, msg) = update_section_line(changed, section_lines, index, changed_lines, newline, msg)
if len(values) == 0:
break
# remove all remaining option occurrences from the rest of the section
for index in range(len(section_lines) - 1, 0, -1):
if not changed_lines[index] and match_active_opt(option, section_lines[index]):
if not changed_lines[index] and match_opt(option, section_lines[index]):
del section_lines[index]
del changed_lines[index]
changed = True

View File

@@ -59,7 +59,7 @@ options:
record_values:
description:
- Manage DNS record name with this value.
- Mutually exclusive with I(record_values), and exactly one of I(record_value) and I(record_values) has to be specified.
- Mutually exclusive with I(record_value), and exactly one of I(record_value) and I(record_values) has to be specified.
- In the case of 'A' or 'AAAA' record types, this will be the IP address.
- In the case of 'A6' record type, this will be the A6 Record data.
- In the case of 'CNAME' record type, this will be the hostname.

View File

@@ -453,7 +453,7 @@
- content17 == expected17
- name: "test-values 18 - Ensure 'beverage=coke' is 'abesent' in section '[drinks]'"
- name: "test-values 18 - Ensure 'beverage=coke' is 'absent' in section '[drinks]'"
ini_file:
path: "{{ output_file }}"
section: drinks
@@ -483,7 +483,7 @@
- content18 == expected18
- name: "test-values 19 - Ensure non-existant 'beverage=coke' is 'abesent' in section '[drinks]'"
- name: "test-values 19 - Ensure non-existent 'beverage=coke' is 'absent' in section '[drinks]'"
ini_file:
path: "{{ output_file }}"
section: drinks
@@ -579,8 +579,8 @@
[section1]
var1 = aaa
# comment in section
var2 = foo
# var2 = bar
# var2 = some value
# comment after section
[section2]
var3 = ccc
@@ -613,8 +613,8 @@
[section1]
var1 = aaa
# comment in section
var2 = foo
# var2 = bar
# var2 = some value
# comment after section
[section2]
var3 = ccc
@@ -629,14 +629,13 @@
- content22 == expected22
- name: "test-values 23 - Ensure 'var2=[foo, foobar]' is 'present' in section '[section1]'"
- name: "test-values 23 - Ensure 'var2=foo' is 'present' in section '[section1]', replacing commented option 'var2=some value'"
ini_file:
path: "{{ output_file }}"
section: section1
option: var2
values:
- foo
- foobar
state: present
register: result23
@@ -647,7 +646,6 @@
- name: test-values 23 - set expected content and get current ini file content
set_fact:
content23: "{{ output_content.content | b64decode }}"
expected23: |
# Some comment to test
@@ -659,28 +657,28 @@
var1 = aaa
# comment in section
var2 = foo
var2 = foobar
# var2 = bar
# comment after section
[section2]
var3 = ccc
# comment after section
- name: test-values 23 - assert 'changed' and msg 'option added' and content is as expected
content23: "{{ output_content.content | b64decode }}"
- name: test-values 23 - assert 'changed' and msg 'option changed' and content is as expected
assert:
that:
- result23 is changed
- result23.msg == 'option added'
- result23.msg == 'option changed'
- content23 == expected23
- name: "test-values 24 - Ensure 'var2=[foo, foobar, bar]' is 'present' in section '[section1]' replacing commented option 'var2=bar'"
- name: "test-values 24 - Ensure 'var2=[foo, foobar]' is 'present' in section '[section1]'"
ini_file:
path: "{{ output_file }}"
section: section1
option: var2
values:
values:
- foo
- bar
- foobar
state: present
register: result24
@@ -692,7 +690,6 @@
- name: test-values 24 - set expected content and get current ini file content
set_fact:
content24: "{{ output_content.content | b64decode }}"
expected24: |
# Some comment to test
@@ -705,16 +702,18 @@
# comment in section
var2 = foo
var2 = foobar
var2 = bar
# comment after section
[section2]
var3 = ccc
# comment after section
- name: test-values 24 - assert 'added' and msg 'option changed' and content is as expected
content24: "{{ output_content.content | b64decode }}"
- name: test-values 24 - assert 'changed' and msg 'option added' and content is as expected
assert:
that:
- result24 is changed
- result24.msg == 'option changed'
- result24.msg == 'option added'
- content24 == expected24

View File

@@ -0,0 +1,7 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
dependencies:
- setup_remote_tmp_dir

View File

@@ -11,16 +11,16 @@
# Create basic CSV file
- name: Create unique CSV file
copy:
content: |
content: &users_content |
name,uid,gid,gecos
dag,500,500,Dag Wieërs
jeroen,501,500,Jeroen Hoekx
dest: users_unique.csv
dest: "{{ remote_tmp_dir }}/users_unique.csv"
# Read a CSV file and access user 'dag'
- name: Read users from CSV file and return a dictionary
read_csv:
path: users_unique.csv
path: "{{ remote_tmp_dir }}/users_unique.csv"
key: name
register: users_unique
@@ -35,10 +35,10 @@
- users_unique.dict.jeroen.uid == '501'
- users_unique.dict.jeroen.gid == '500'
# Read a CSV file and access the first item
# Read a CSV file and access the first item
- name: Read users from CSV file and return a list
read_csv:
path: users_unique.csv
path: "{{ remote_tmp_dir }}/users_unique.csv"
register: users_unique
- assert:
@@ -61,12 +61,12 @@
dag;500;500;Dag Wieërs
jeroen;501;500;Jeroen Hoekx
dag;502;500;Dag Wieers
dest: users_nonunique.csv
dest: "{{ remote_tmp_dir }}/users_nonunique.csv"
# Read a CSV file and access user 'dag'
- name: Read users from CSV file and return a dictionary
read_csv:
path: users_nonunique.csv
path: "{{ remote_tmp_dir }}/users_nonunique.csv"
key: name
unique: false
delimiter: ';'
@@ -87,7 +87,7 @@
# Read a CSV file using an non-existing dialect
- name: Read users from CSV file and return a dictionary
read_csv:
path: users_nonunique.csv
path: "{{ remote_tmp_dir }}/users_nonunique.csv"
dialect: placebo
register: users_placebo
ignore_errors: true
@@ -104,12 +104,12 @@
content: |
dag,500,500,Dag Wieërs
jeroen,501,500,Jeroen Hoekx
dest: users_noheader.csv
dest: "{{ remote_tmp_dir }}/users_noheader.csv"
# Read a CSV file and access user 'dag'
- name: Read users from CSV file and return a dictionary
read_csv:
path: users_noheader.csv
path: "{{ remote_tmp_dir }}/users_noheader.csv"
key: name
fieldnames: name,uid,gid,gecos
register: users_noheader
@@ -133,12 +133,12 @@
name,uid,gid,gecos
dag,500,500,Dag Wieërs
jeroen,501,500,"Jeroen"Hoekx"
dest: users_broken.csv
dest: "{{ remote_tmp_dir }}/users_broken.csv"
# Read a broken CSV file using strict
- name: Read users from a broken CSV file
read_csv:
path: users_broken.csv
path: "{{ remote_tmp_dir }}/users_broken.csv"
key: name
strict: true
register: users_broken
@@ -148,3 +148,29 @@
that:
- users_broken is failed
- "'Unable to process file' in users_broken.msg"
# Create basic CSV file with BOM
- name: Create unique CSV file with BOM
copy:
content: "{{ bom + content }}"
dest: "{{ remote_tmp_dir }}/users_bom.csv"
vars:
content: *users_content
bom: "{{ '\ufeff' }}"
# Read a CSV file and access the first item
- name: Read users from CSV file and return a list
read_csv:
path: "{{ remote_tmp_dir }}/users_bom.csv"
register: users_bom
- assert:
that:
- users_bom.list.0.name == 'dag'
- users_bom.list.0.gecos == 'Dag Wieërs'
- users_bom.list.0.uid == '500'
- users_bom.list.0.gid == '500'
- users_bom.list.1.name == 'jeroen'
- users_bom.list.1.gecos == 'Jeroen Hoekx'
- users_bom.list.1.uid == '501'
- users_bom.list.1.gid == '500'

View File

@@ -0,0 +1,103 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import unittest
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import is_struct_included
class KeycloakIsStructIncludedTestCase(unittest.TestCase):
dict1 = dict(
test1='test1',
test2=dict(
test1='test1',
test2='test2'
),
test3=['test1', dict(test='test1', test2='test2')]
)
dict2 = dict(
test1='test1',
test2=dict(
test1='test1',
test2='test2',
test3='test3'
),
test3=['test1', dict(test='test1', test2='test2'), 'test3'],
test4='test4'
)
dict3 = dict(
test1='test1',
test2=dict(
test1='test1',
test2='test23',
test3='test3'
),
test3=['test1', dict(test='test1', test2='test23'), 'test3'],
test4='test4'
)
dict5 = dict(
test1='test1',
test2=dict(
test1=True,
test2='test23',
test3='test3'
),
test3=['test1', dict(test='test1', test2='test23'), 'test3'],
test4='test4'
)
dict6 = dict(
test1='test1',
test2=dict(
test1='true',
test2='test23',
test3='test3'
),
test3=['test1', dict(test='test1', test2='test23'), 'test3'],
test4='test4'
)
dict7 = [
{
'roles': ['view-clients', 'view-identity-providers', 'view-users', 'query-realms', 'manage-users'],
'clientid': 'master-realm'
},
{
'roles': ['manage-account', 'view-profile', 'manage-account-links'],
'clientid': 'account'
}
]
dict8 = [
{
'roles': ['view-clients', 'query-realms', 'view-users'],
'clientid': 'master-realm'
},
{
'roles': ['manage-account-links', 'view-profile', 'manage-account'],
'clientid': 'account'
}
]
def test_trivial(self):
self.assertTrue(is_struct_included(self.dict1, self.dict1))
def test_equals_with_dict2_bigger_than_dict1(self):
self.assertTrue(is_struct_included(self.dict1, self.dict2))
def test_not_equals_with_dict2_bigger_than_dict1(self):
self.assertFalse(is_struct_included(self.dict2, self.dict1))
def test_not_equals_with_dict1_different_than_dict3(self):
self.assertFalse(is_struct_included(self.dict1, self.dict3))
def test_equals_with_dict5_contain_bool_and_dict6_contain_true_string(self):
self.assertFalse(is_struct_included(self.dict5, self.dict6))
self.assertFalse(is_struct_included(self.dict6, self.dict5))
def test_not_equals_dict7_dict8_compare_dict7_with_list_bigger_than_dict8_but_reverse_equals(self):
self.assertFalse(is_struct_included(self.dict7, self.dict8))
self.assertTrue(is_struct_included(self.dict8, self.dict7))

View File

@@ -21,6 +21,7 @@ pycrypto >= 2.6 # Need features found in 2.6 and greater
ncclient >= 0.5.2 # Need features added in 0.5.2 and greater
idna < 2.6, >= 2.5 # linode requires idna < 2.9, >= 2.5, requests requires idna < 2.6, but cryptography will cause the latest version to be installed instead
paramiko < 2.4.0 ; python_version < '2.7' # paramiko 2.4.0 drops support for python 2.6
python-nomad < 2.0.0 ; python_version <= '3.7' # python-nomad 2.0.0 needs Python 3.7+
pytest < 3.3.0 ; python_version < '2.7' # pytest 3.3.0 drops support for python 2.6
pytest < 5.0.0 ; python_version == '2.7' # pytest 5.0.0 and later will no longer support python 2.7
pytest-forked < 1.0.2 ; python_version < '2.7' # pytest-forked 1.0.2 and later require python 2.7 or later