Skip to content

Commit

Permalink
feat: add description parameter to location
Browse files Browse the repository at this point in the history
  • Loading branch information
PfurtschellerP authored and evgeni committed Jul 25, 2024
1 parent e76f0a3 commit 7328570
Show file tree
Hide file tree
Showing 35 changed files with 3,193 additions and 2,400 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1724-location_description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- location, locations role - add ``description`` parameter to set the description
7 changes: 7 additions & 0 deletions plugins/modules/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
- Name of the Location
required: true
type: str
description:
description:
- Description of the Location
required: false
type: str
version_added: 4.2.0
parent:
description:
- Title of a parent Location for nesting
Expand Down Expand Up @@ -123,6 +129,7 @@ def main():
module = ForemanLocationModule(
foreman_spec=dict(
name=dict(required=True),
description=dict(required=False),
parent=dict(type='entity'),
organizations=dict(type='entity_list'),
ignore_types=dict(type='list', elements='str', required=False, aliases=['select_all_types']),
Expand Down
1 change: 1 addition & 0 deletions roles/locations/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
server_url: "{{ foreman_server_url | default(omit) }}"
validate_certs: "{{ foreman_validate_certs | default(omit) }}"
name: "{{ item.name }}"
description: "{{ item.description | default(omit) }}"
parent: "{{ item.parent | default(omit) }}"
organizations: "{{ item.organizations | default(omit) }}"
parameters: "{{ item.parameters | default(omit) }}"
Expand Down
226 changes: 118 additions & 108 deletions tests/test_playbooks/fixtures/location-0.yml

Large diffs are not rendered by default.

230 changes: 120 additions & 110 deletions tests/test_playbooks/fixtures/location-1.yml

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions tests/test_playbooks/fixtures/location-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ interactions:
uri: https://foreman.example.org/api/status
response:
body:
string: '{"result":"ok","status":200,"version":"3.4.0","api_version":2}'
string: '{"result":"ok","status":200,"version":"3.11.0-develop","api_version":2}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '71'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -33,13 +35,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=100
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -71,15 +71,17 @@ interactions:
string: "{\n \"total\": 5,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\":
4294967296,\n \"search\": \"title=\\\"Test Location/Sub Location 1/Sub Location
2\\\"\",\n \"sort\": {\n \"by\": null,\n \"order\": null\n },\n \"results\":
[{\"ancestry\":\"4/5\",\"parent_id\":5,\"parent_name\":\"Test Location/Sub
Location 1\",\"created_at\":\"2022-11-08 09:29:09 UTC\",\"updated_at\":\"2022-11-08
09:29:09 UTC\",\"id\":6,\"name\":\"Sub Location 2\",\"title\":\"Test Location/Sub
[{\"ancestry\":\"7/8\",\"parent_id\":8,\"parent_name\":\"Test Location/Sub
Location 1\",\"created_at\":\"2024-07-25 12:00:07 UTC\",\"updated_at\":\"2024-07-25
12:00:07 UTC\",\"id\":9,\"name\":\"Sub Location 2\",\"title\":\"Test Location/Sub
Location 1/Sub Location 2\",\"description\":null}]\n}\n"
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '469'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -93,13 +95,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=99
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -131,14 +131,16 @@ interactions:
string: "{\n \"total\": 5,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\":
4294967296,\n \"search\": \"title=\\\"Test Location/Sub Location 1\\\"\",\n
\ \"sort\": {\n \"by\": null,\n \"order\": null\n },\n \"results\":
[{\"ancestry\":\"4\",\"parent_id\":4,\"parent_name\":\"Test Location\",\"created_at\":\"2022-11-08
09:29:07 UTC\",\"updated_at\":\"2022-11-08 09:29:07 UTC\",\"id\":5,\"name\":\"Sub
[{\"ancestry\":\"7\",\"parent_id\":7,\"parent_name\":\"Test Location\",\"created_at\":\"2024-07-25
12:00:04 UTC\",\"updated_at\":\"2024-07-25 12:00:04 UTC\",\"id\":8,\"name\":\"Sub
Location 1\",\"title\":\"Test Location/Sub Location 1\",\"description\":null}]\n}\n"
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '422'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -152,13 +154,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=98
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -186,16 +186,18 @@ interactions:
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: DELETE
uri: https://foreman.example.org/api/locations/6
uri: https://foreman.example.org/api/locations/9
response:
body:
string: '{"id":6,"name":"Sub Location 2","created_at":"2022-11-08T09:29:09.414Z","updated_at":"2022-11-08T09:29:09.414Z","ignore_types":[],"ancestry":"4/5","title":"Test
string: '{"id":9,"name":"Sub Location 2","created_at":"2024-07-25T12:00:07.163Z","updated_at":"2024-07-25T12:00:07.163Z","ignore_types":[],"ancestry":"7/8","title":"Test
Location/Sub Location 1/Sub Location 2","description":null}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '220'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -209,13 +211,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=97
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down
38 changes: 19 additions & 19 deletions tests/test_playbooks/fixtures/location-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ interactions:
uri: https://foreman.example.org/api/status
response:
body:
string: '{"result":"ok","status":200,"version":"3.4.0","api_version":2}'
string: '{"result":"ok","status":200,"version":"3.11.0-develop","api_version":2}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '71'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -33,13 +35,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=100
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -71,14 +71,16 @@ interactions:
string: "{\n \"total\": 4,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\":
4294967296,\n \"search\": \"title=\\\"Test Location/Sub Location 1\\\"\",\n
\ \"sort\": {\n \"by\": null,\n \"order\": null\n },\n \"results\":
[{\"ancestry\":\"4\",\"parent_id\":4,\"parent_name\":\"Test Location\",\"created_at\":\"2022-11-08
09:29:07 UTC\",\"updated_at\":\"2022-11-08 09:29:07 UTC\",\"id\":5,\"name\":\"Sub
[{\"ancestry\":\"7\",\"parent_id\":7,\"parent_name\":\"Test Location\",\"created_at\":\"2024-07-25
12:00:04 UTC\",\"updated_at\":\"2024-07-25 12:00:04 UTC\",\"id\":8,\"name\":\"Sub
Location 1\",\"title\":\"Test Location/Sub Location 1\",\"description\":null}]\n}\n"
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '422'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -92,13 +94,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=99
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -129,14 +129,16 @@ interactions:
body:
string: "{\n \"total\": 4,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\":
4294967296,\n \"search\": \"title=\\\"Test Location\\\"\",\n \"sort\": {\n
\ \"by\": null,\n \"order\": null\n },\n \"results\": [{\"ancestry\":null,\"parent_id\":null,\"parent_name\":null,\"created_at\":\"2022-11-08
09:29:05 UTC\",\"updated_at\":\"2022-11-08 09:29:05 UTC\",\"id\":4,\"name\":\"Test
\ \"by\": null,\n \"order\": null\n },\n \"results\": [{\"ancestry\":null,\"parent_id\":null,\"parent_name\":null,\"created_at\":\"2024-07-25
12:00:01 UTC\",\"updated_at\":\"2024-07-25 12:00:01 UTC\",\"id\":7,\"name\":\"Test
Location\",\"title\":\"Test Location\",\"description\":null}]\n}\n"
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '384'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -150,13 +152,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=98
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -184,16 +184,18 @@ interactions:
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: DELETE
uri: https://foreman.example.org/api/locations/5
uri: https://foreman.example.org/api/locations/8
response:
body:
string: '{"id":5,"name":"Sub Location 1","created_at":"2022-11-08T09:29:07.656Z","updated_at":"2022-11-08T09:29:07.656Z","ignore_types":[],"ancestry":"4","title":"Test
string: '{"id":8,"name":"Sub Location 1","created_at":"2024-07-25T12:00:04.339Z","updated_at":"2024-07-25T12:00:04.339Z","ignore_types":[],"ancestry":"7","title":"Test
Location/Sub Location 1","description":null}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '203'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
Expand All @@ -207,13 +209,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.4.0
- 3.11.0-develop
Keep-Alive:
- timeout=15, max=97
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down
Loading

0 comments on commit 7328570

Please sign in to comment.