Skip to content

Commit

Permalink
chore(make_docs): apply linting fixes
Browse files Browse the repository at this point in the history
remove trailing spaces
fix relative links
indentation
add error to ansible-lint-ignore
Capitalise Centurion ERP
  • Loading branch information
jasonpagetas committed Aug 19, 2024
1 parent 8579a59 commit eee170f
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 160 deletions.
6 changes: 5 additions & 1 deletion .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
galaxy.yml galaxy[version-incorrect]
galaxy.yml galaxy[version-incorrect]
# This playbook will only ever be run against the centurion host
playbooks/teams.yaml run-once[task]
# This task only saves the report on the local machine and is deleted after uploading
playbooks/inventory.yaml risky-file-permissions
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ On import to AWX / Ansible Automation Platform a credential type will also be cr


!!! warning
The inventory playbook currently has an issue relating to gathering software starting with L. This issue has been reported and is being worked on https://github.com/nofusscomputing/ansible_collection_centurion/issues/19
The inventory playbook currently has an issue relating to gathering software starting with L. This issue has been reported and is being worked on
[github issue 19](https://github.com/nofusscomputing/ansible_collection_centurion/issues/19)


## Play workflow
Expand Down
6 changes: 3 additions & 3 deletions docs/projects/ansible/collection/centurion/playbooks/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ The following job template will be created:


!!! info
The playbook is able to work with centurion ERP directly or using the inventory pluggin that is included in this collection.
The playbook is able to work with Centurion ERP directly or using the inventory pluggin that is included in this collection.


## Play workflow

The teams playbook gathers information regarding centurion organisations from the ansible inventory. Using this information the play is designed to create new teams, patch permissions and patch notes. The workflow for the playbook is as follows

- Fetch all organisations from centurion
- Fetch all existing teams within each organisation from centurion
- Fetch all organisations from Centurion ERP
- Fetch all existing teams within each organisation from Centurion ERP
- Fetch any teams to be created from inventory
- Create new teams
- Patch all teams with required permissions
Expand Down
Empty file.
177 changes: 88 additions & 89 deletions playbooks/inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@

- name: Inventory host
block:
- name: fetch Packages
ansible.builtin.package_facts:
manager: auto
become: true


- name: Inventory Details
ansible.builtin.set_fact:
details: {
"name": "{{ ansible_hostname }}",
"serial_number": "{{ ansible_product_serial }}",
"uuid": "{{ ansible_product_uuid }}"
}


- name: Inventory Software [a-k]
ansible.builtin.set_fact:
cacheable: false
software: "{{ software | default([]) + [{
'name': package.value[0].name,
'category': package.value[0].category | default(''),
'version': package.value[0].version
}] }}"
# no_log: true
loop: "{{ ansible_facts.packages | dict2items() }}"
loop_control:
loop_var: package
label: "{{ package.key }}"
when: >
package.value[0].name | regex_search("^[a-k]")

- name: Fetch Packages
ansible.builtin.package_facts:
manager: auto
become: true


- name: Inventory Details
ansible.builtin.set_fact:
details: {
"name": "{{ ansible_hostname }}",
"serial_number": "{{ ansible_product_serial }}",
"uuid": "{{ ansible_product_uuid }}"
}


- name: Inventory Software [a-k]
ansible.builtin.set_fact:
cacheable: false
software: "{{ software | default([]) + [{
'name': package.value[0].name,
'category': package.value[0].category | default(''),
'version': package.value[0].version
}] }}"
# no_log: true
loop: "{{ ansible_facts.packages | dict2items() }}"
loop_control:
loop_var: package
label: "{{ package.key }}"
when: >
package.value[0].name | regex_search("^[a-k]")
# https://github.com/nofusscomputing/ansible_collection_centurion/issues/19

Expand All @@ -55,7 +55,7 @@
# software: "{{ software | default([]) + [{
# 'name': package.value[0].name,
# 'category': package.value[0].category | default(''),
# 'version': package.value[0].version
# 'version': package.value[0].version
# }] }}"
# # no_log: true
# loop: "{{ ansible_facts.packages | dict2items() }}"
Expand All @@ -66,66 +66,66 @@
# package.value[0].name | regex_search("^[l]")


- name: Inventory Software [m-z]
ansible.builtin.set_fact:
cacheable: false
software: "{{ software | default([]) + [{
'name': package.value[0].name,
'category': package.value[0].category | default(''),
'version': package.value[0].version
}] }}"
# no_log: true
loop: "{{ ansible_facts.packages | dict2items() }}"
loop_control:
loop_var: package
label: "{{ package.key }}"
when: >
package.value[0].name | regex_search("^[m-z]")
- name: Inventory Document
ansible.builtin.set_fact:
report: {
"details": "{{ details }}",
"os": {
"name": "{{ ansible_distribution | lower }}",
"version": "{{ ansible_distribution_version }}",
"version_major": "{{ ansible_distribution_major_version }}"
},
"software": "{{ software }}"
}


- name: Save report
ansible.builtin.copy:
content: "{{ report | to_nice_json }}"
dest: "/tmp/{{ ansible_hostname }}.json"

- name: Upload inventory - {{ ansible_hostname }}
ansible.builtin.uri:
url: |-
{{ lookup('env', 'ITSM_API') }}/api/device/inventory
method: POST
body_format: json
src: "/tmp/{{ ansible_hostname }}.json"
remote_src: true
headers:
Authorization: Token {{ lookup('env', 'ITSM_TOKEN') }}
validate_certs: "{{ lookup('env', 'ITSM_VALIDATE_CERTS') | default(true) | bool }}"
timeout: 300
status_code:
- 200
- 201
no_log: > # Contains a secret that logging shows
{{ nfc_pb_disable_log | default(true) }}
- name: Inventory Software [m-z]
ansible.builtin.set_fact:
cacheable: false
software: "{{ software | default([]) + [{
'name': package.value[0].name,
'category': package.value[0].category | default(''),
'version': package.value[0].version
}] }}"
# no_log: true
loop: "{{ ansible_facts.packages | dict2items() }}"
loop_control:
loop_var: package
label: "{{ package.key }}"
when: >
package.value[0].name | regex_search("^[m-z]")
- name: Inventory Document
ansible.builtin.set_fact:
report: {
"details": "{{ details }}",
"os": {
"name": "{{ ansible_distribution | lower }}",
"version": "{{ ansible_distribution_version }}",
"version_major": "{{ ansible_distribution_major_version }}"
},
"software": "{{ software }}"
}


- name: Save report
ansible.builtin.copy:
content: "{{ report | to_nice_json }}"
dest: "/tmp/{{ ansible_hostname }}.json"


- name: Upload inventory - {{ ansible_hostname }}
ansible.builtin.uri:
url: |-
{{ lookup('env', 'ITSM_API') }}/api/device/inventory
method: POST
body_format: json
src: "/tmp/{{ ansible_hostname }}.json"
remote_src: true
headers:
Authorization: Token {{ lookup('env', 'ITSM_TOKEN') }}
validate_certs: "{{ lookup('env', 'ITSM_VALIDATE_CERTS') | default(true) | bool }}"
timeout: 300
status_code:
- 200
- 201
no_log: > # Contains a secret that logging shows
{{ nfc_pb_disable_log | default(true) }}
always:
- name: Remove report
ansible.builtin.file:
path: "/tmp/{{ ansible_hostname }}.json"
path: "/tmp/{{ ansible_hostname }}.json"
state: absent

vars:
Expand Down Expand Up @@ -173,4 +173,3 @@
CENTURION_API: '{{ centurion_url }}'
CENTURION_TOKEN: '{{ centurion_token }}'
CENTURION_VALIDATE_CERTS: '{{ centurion_validate_certs | default(true) }}'
Loading

0 comments on commit eee170f

Please sign in to comment.