Skip to content

Commit

Permalink
Add playbook to setup user accounts (#20)
Browse files Browse the repository at this point in the history
- add `playbooks/setup_user_accounts.yml` playbook
- uses the role `provision_accounts` to setup OS users
- update README with brief description of the playbook
- test the `provision_accounts` role via this playbook
  • Loading branch information
p-j-smith authored Dec 15, 2023
1 parent 1f06b0a commit 97ccd7b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/molecule-provision_accounts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
paths:
- "roles/provision_accounts/**"
- "playbooks/setup_user_accounts.yml"
- ".github/workflows/molecule.yml"
- ".github/workflows/molecule-provision_accounts.yml"

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/UCL-MIRSG/.github
rev: v0.36.0
rev: v0.38.0
hooks:
- id: mirsg-hooks
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
This repository contains the `mirsg.infrastructure` Ansible Collection. This collection can be used to
configure infrastructure for deploying XNAT and OMERO.

## Included content

### Playbooks

| Name | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
| [setup_user_accounts.yml](playbooks/setup_user_accounts.yml) | Create OS user accounts a group of servers `target`, which defaults to `all`. |

## External requirements

Before using this collection and its playbooks, you must install the
Expand All @@ -27,8 +35,8 @@ collections:
## Testing this collection
We use [Ansible Molecule](https://ansible.readthedocs.io/projects/molecule/) and its
[Docker plugin](https://github.com/ansible-community/molecule-plugins) to test the roles in
this collection.
[Docker plugin](https://github.com/ansible-community/molecule-plugins) to test the roles
and playbooks in this collection.
If you would like to run the tests locally you will need to:
Expand Down
10 changes: 10 additions & 0 deletions playbooks/setup_user_accounts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Create user accounts on targeted servers
hosts: "{{ target | default('all') }}"
become: true
become_user: root
become_method: ansible.builtin.sudo
gather_facts: true

roles:
- role: provision_accounts
1 change: 0 additions & 1 deletion roles/provision_accounts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
# tasks file for provision_accounts

- name: Create OS user accounts from variables
ansible.builtin.user:
user: "{{ item.username }}"
Expand Down
7 changes: 4 additions & 3 deletions tests/molecule/resources/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
- role: mirsg.infrastructure.provision
tags: provision

- role: mirsg.infrastructure.provision_accounts
tags: provision_accounts

- role: mirsg.infrastructure.install_python
tags: python

Expand All @@ -18,3 +15,7 @@

- role: mirsg.infrastructure.postgresql
tags: postgresql

- name: Provision infrastructure with playbooks
ansible.builtin.import_playbook: mirsg.infrastructure.setup_user_accounts
tags: provision_accounts

0 comments on commit 97ccd7b

Please sign in to comment.