Skip to content

Commit

Permalink
- add truenas_group_debug tag
Browse files Browse the repository at this point in the history
- set fact of existing groups after create/update/delete tasks
  • Loading branch information
e88z4 committed Jan 21, 2022
1 parent ea85a23 commit 3aad5c1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
56 changes: 54 additions & 2 deletions tasks/group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,37 @@
delegate_to: localhost
tags:
- truenas_group
- truenas_user
- truenas_group_debug
- truenas_user_debug

- name: group | setting group configuration fact
set_fact:
truenas_group_config: "{{ lookup('template', 'group.j2') }}"
tags:
- truenas_group
- truenas_user
- truenas_group_debug
- truenas_user_debug

- name: group | print group fact
debug:
msg: "{{ truenas_group_config }}"
tags:
- truenas_group
- truenas_user_debug
- truenas_group_debug


- name: group | terminate if any built-in groups (id<1000) is modified
- name: group | terminate if any built-in groups is modified
fail:
msg: "{{ item.name + ' is a built-in group' }}"
when: truenas_group_config.built_in_groups | length > 0
with_items: "{{ truenas_group_config.built_in_groups }}"
tags:
- truenas_user
- truenas_group
- truenas_group_debug
- truenas_user_debug

- name: group | create group
uri:
Expand All @@ -43,7 +54,10 @@
with_items: "{{ truenas_group_config.create_groups }}"
delegate_to: localhost
tags:
- truenas_user
- truenas_group
- truenas_group_debug
- truenas_user_debug

- name: group | update group
uri:
Expand All @@ -57,7 +71,10 @@
with_items: "{{ truenas_group_config.update_groups }}"
delegate_to: localhost
tags:
- truenas_user
- truenas_group
- truenas_group_debug
- truenas_user_debug

- name: group | delete_group
uri:
Expand All @@ -69,5 +86,40 @@
with_items: "{{ truenas_group_config.delete_groups }}"
delegate_to: localhost
tags:
- truenas_user
- truenas_user_debug
- truenas_group
- truenas_group_debug

- name: group | get all groups
uri:
url: "{{ truenas_api_url + '/group' }}"
force_basic_auth: true
method: "GET"
user: "{{ truenas_api_user }}"
password: "{{ truenas_api_password }}"
register: truenas_group_found
delegate_to: localhost
tags:
- truenas_user
- truenas_user_debug
- truenas_group
- truenas_group_debug

- name: group | setting group configuration fact
set_fact:
truenas_group_config: "{{ lookup('template', 'group.j2') }}"
tags:
- truenas_user
- truenas_user_debug
- truenas_group
- truenas_group_debug

- name: group | print all group
debug:
msg: "{{ truenas_group_config.existing_groups }}"
delegate_to: localhost
tags:
- truenas_user_debug
- truenas_group_debug

5 changes: 5 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
- include_tasks: update.yml
tags:
- truenas_update
- truenas_update_debug

- include_tasks: group.yml
tags:
- truenas_group
- truenas_user
- truenas_user_debug
- truenas_group_debug

- include_tasks: user.yml
tags:
- truenas_user
- truneas_user_debug
3 changes: 2 additions & 1 deletion templates/group.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
'create_groups': create_groups,
'update_groups': update_groups,
'delete_groups': delete_groups,
'built_in_groups': built_in_groups
'built_in_groups': built_in_groups,
'existing_groups': existing_groups
})
%}
{{ truenas_groups }}

0 comments on commit 3aad5c1

Please sign in to comment.