diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..04cc528 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/ansible/ansible-lint + rev: v6.20.0 + hooks: + - id: ansible-lint + - repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + diff --git a/README.md b/README.md index a88254c..55d4152 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,56 @@ # ansible-playground +This collection includes tasks to configure SSH and add local user accounts. It verifies the SSH configuration and creates the specified users with specific attributes. + +## Usage + +### 1. Install the Collection + +```bash +ansible-galaxy collection install git+https://git.slc.ar/slococo/ansible-playground.git#/slococo/playground +``` + +### 2. Create an inventory file + +Create an inventory file (e.g., `inventory`) with the following content: + +``` +[all] +target_host ansible_host= ansible_user= ansible_connection=ssh ansible_ssh_private_key_file= +``` + +Replace `` with the IP address or hostname of your target host, `` with the SSH username, and `` with the path to the SSH private key file. + +### 3. Run the Playbook + +```bash +ansible-playbook -i inventory slococo.playground.main +``` + +### Expected outcome + +Upon successful execution, the playbook will: + +- Create the users `local_adm` and `local_log` with the specified attributes. +- Verify the SSH configuration with the provided settings: + - `PasswordAuthentication`: yes + - `PermitEmptyPasswords`: no + - `PermitRootLogin`: no + +### User configuration + +#### `local_adm`: +- Username: `local_adm` +- Shell: `/bin/bash` +- User ID: `38000087` +- Expiry Date: The account should not expire. +- Home Directory: `/home/local_adm` +- Groups: The user should only belong to its primary group. + +#### `local_log`: +- Username: `local_log` +- Shell: `/bin/sh` +- User ID: `38000088` +- Expiry Date: The account should expire at the end of 2024. +- Home Directory: `/home/local_log` +- Groups: The user should only belong to its primary group.