Ansible Role: serdigital64.storage.stg_repository¶
Purpose¶
Manage file repositories provisioning.
File repositories are simple directory structures that are created as resources for other roles to consume such as NFS servers, GIT servers, Samba servers, etc.
Supported features in the current version:
- Provision repositories:
- Create repository owners
- Users
- Groups
- Create repository location
- Create directory
- Set ownership
- Set access permissions
- Create repository owners
The stg_repository Ansible-Role is part of the A:Platform64 project and is available in the storage Ansible-Collection.
Usage¶
The following example is an Ansible Playbook that includes all the supported features:
use this link if viewing the doc on github
---
- name: "Storage / Repository / Usage example"
hosts: "localhost"
gather_facts: true
vars:
test_stg_repositories_resource:
base:
path: "/srv/fs"
user: "root"
group: "root"
mode: "0755"
test1:
path: "/srv/fs/test1"
user: "test1"
group: "group1"
mode: "0750"
test2:
path: "/srv/fs/test2"
user: "test2"
group: "group2"
mode: "0750"
test_stg_repositories_users:
- name: "test1"
uid: "10000"
group: "test1"
shell: "/bin/false"
groups:
- "group1"
- name: "test2"
uid: "10001"
group: "test2"
shell: "/bin/false"
groups:
- "group2"
test_stg_repositories_groups:
- name: "group1"
gid: "9000"
- name: "group2"
gid: "9001"
tasks:
- name: "Example: create owning group and user, create repository"
vars:
stg_nfs_reposittory:
prepare: true
provision: true
stg_repositories_users: "{{ test_stg_repositories_users }}"
stg_repositories_groups: "{{ test_stg_repositories_groups }}"
stg_repositories_resource: "{{ test_stg_repositories_resource }}"
ansible.builtin.include_role:
name: "serdigital64.storage.stg_nfs_reposittory"
...
The playbook can be run by executing:
# Set ANSIBLE_COLLECTIONS_PATHS to the default location. Change as needed.
ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible/collections"
ansible-playbook "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/serdigital64/storage/playbooks/stg_repository.yml"
Role Parameters¶
Actions¶
- Use action-parameters to control what tasks are enabled for the role to execute.
- Parameters should be declared as task level vars as they are intented to be dynamic.
stg_repository:
prepare:
provision:
Parameter | Required? | Type | Default | Purpose / Value |
---|---|---|---|---|
stg_repository.prepare | no | boolean | false | Enable creationg of owners |
stg_repository.provision | no | boolean | false | Enable provisioning of repositories |
End State¶
- Use end-state parameters to define the target state after role execution.
- Parameters should be declared in host_vars or group_vars as they are intended to be permanent.
stg_repositories_resources:
<SHARE>:
path:
user:
group:
mode:
stg_repositories_users:
- name:
uid:
group:
shell:
groups:
-
stg_repositories_groups:
- name:
gid:
Parameter | Required? | Type | Default | Purpose / Value |
---|---|---|---|---|
stg_repositories_resources | yes(provision) | dictionary | Repositories catalog | |
stg_repositories_resources. | yes | dictionary | Repository definition | |
stg_repositories_resources. | yes | string | Full path | |
stg_repositories_resources. | yes | string | Owning user | |
stg_repositories_resources. | yes | string | Owning group | |
stg_repositories_resources. | yes | string | Directory permissions (octal) | |
stg_repositories_users | no | list | Owning users catalog | |
stg_repositories_users.0 | no | list | Owning user definition | |
stg_repositories_users.0.name | yes | string | Login name | |
stg_repositories_users.0.uid | no | string | User ID | |
stg_repositories_users.0.group | no | string | Primary group name | |
stg_repositories_users.0.shell | no | string | Full path to the shell | |
stg_repositories_users.0.groups | no | list | List of secondary groups | |
stg_repositories_users.0.groups.0.name | no | string | Group name | |
stg_repositories_groups | no | list | Owning groups catalog | |
stg_repositories_groups.0 | no | list | Group definition | |
stg_repositories_groups.0.name | yes | string | Name | |
stg_repositories_groups.0.gid | no | string | Group ID |
Deployment¶
OS Compatibility¶
The operating system compatibility list is defined in the variable: stg_repository_platforms
Dependencies¶
- Ansible Collections:
- serdigital64.system
- sys_user
- serdigital64.system
Prerequisites¶
The Ansible engine must be already installed and configured for privileged access and remote execution.
In addition the following prerequisites can be automatically solved when running the playbook by setting the role action: resolve_prereq: true
- Package manager for the target application is installed and enabled.
Installation Procedure¶
Manually install Ansible Collections from the Ansible Galaxy repository:
ansible-galaxy collection install serdigital64.storage
Automatic installation is also available by deploying A:Platform64
Contributing¶
Help on implementing new features and maintaining the code base is welcomed.
Please see the guidelines for further details.