Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
8126c26ec3 | |||
4341ba9bc6 | |||
|
65d8112b0d | ||
f3042dbf7e |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1 @@
|
||||
# ---> Ansible
|
||||
*.retry
|
||||
|
||||
.idea
|
||||
|
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,13 +0,0 @@
|
||||
# Change log
|
||||
|
||||
Current version: 0.1.0
|
||||
|
||||
<!--next-version-placeholder-->
|
||||
|
||||
## v0.1.0 (2022-07-24)
|
||||
### Feature
|
||||
* **role:** Introduce Semantic Versioning a changelog ([`a84a113`](https://quico.space/quico-ansible/role_common_local-os-password/commit/a84a113ef749dc7c543f1b3995efe0e4194f7832))
|
||||
* **role:** Initial commit ([`dc9b87b`](https://quico.space/quico-ansible/role_common_local-os-password/commit/dc9b87ba880b58004201199f559b950ada939555))
|
||||
|
||||
### Fix
|
||||
* **role:** Import dependency via 'git+https' protocol ([`8a1aa01`](https://quico.space/quico-ansible/role_common_local-os-password/commit/8a1aa0175efa6acf40f2c85dac45375adf0e92e1))
|
44
README.md
44
README.md
@ -1,3 +1,43 @@
|
||||
# role_common_local-os-password
|
||||
[//]: # (SPDX-License-Identifier: MIT)
|
||||
# Role Name
|
||||
|
||||
An Ansible role to change an operating system's local user password
|
||||
role-common-local_os_password
|
||||
|
||||
# Description
|
||||
|
||||
Change an operating system's local user password.
|
||||
|
||||
# Requirements
|
||||
|
||||
Your target machines must be Linux.
|
||||
|
||||
# Role Variables
|
||||
|
||||
This role requires variables defined in [defaults/main.yml](defaults/main.yml). Feel free to overwrite them as needed for your HashiCorp Vault setup for example in a `group_vars` or `host_vars` file.
|
||||
|
||||
- `fqdn_reverse`: A variable that contains the reversed fully qualified domain name for each host. For `fully.qualified.domain.name` this variable will equal `name/domain/qualified/fully` which we then use in our HashiCorp Vault path to retrieve a password and password salt per host and per user.
|
||||
- `reset_password_for_account`: A list of usernames whose password we want changed. This defaults to:
|
||||
```
|
||||
reset_password_for_account:
|
||||
- 'build'
|
||||
- 'root'
|
||||
```
|
||||
|
||||
# Dependencies
|
||||
|
||||
None.
|
||||
|
||||
# Example Playbook
|
||||
|
||||
In your `playbook.yml` call it like so:
|
||||
|
||||
```
|
||||
- name: 'Awesome playbook'
|
||||
hosts: all
|
||||
roles:
|
||||
- 'role-common-local_os_password'
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
|
5
defaults/main.yml
Normal file
5
defaults/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
fqdn_reverse: '{{ inventory_hostname | split(".") | reverse | join("/") }}'
|
||||
reset_password_for_account:
|
||||
- 'build'
|
||||
- 'root'
|
@ -1,14 +1,10 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
galaxy_info:
|
||||
author: 'hygienic-books'
|
||||
description: 'An Ansible role to change an operating system''s local user password'
|
||||
issue_tracker_url: 'https://quico.space/quico-ansible/role_common_local-os-password/issues'
|
||||
license: 'MIT'
|
||||
min_ansible_version: '2.12.6'
|
||||
platforms:
|
||||
- name: 'EL'
|
||||
versions:
|
||||
- '7'
|
||||
- '8'
|
||||
description: 'Change an operating system''s local user password'
|
||||
license: MIT
|
||||
min_ansible_version: 2.18.1
|
||||
galaxy_tags:
|
||||
- 'os'
|
||||
- 'password'
|
||||
dependencies: []
|
||||
|
@ -1,2 +0,0 @@
|
||||
- src: 'git+https://quico.space/quico-ansible/role_include_vault-check.git'
|
||||
version: 'master'
|
@ -1,33 +1,11 @@
|
||||
- name: 'Get secrets'
|
||||
no_log: 'true'
|
||||
loop_control:
|
||||
loop_var: 'server'
|
||||
with_community.hashi_vault.vault_kv2_get: '{{ local_os_password_vault_paths }}'
|
||||
ansible.builtin.set_fact:
|
||||
vault_data: '{{ vault_data | default({}) | combine (server.secret) }}'
|
||||
|
||||
|
||||
|
||||
- name: 'If a secret is missing: Fail progress'
|
||||
import_role:
|
||||
name: 'role_include_vault-check'
|
||||
vars:
|
||||
- vault_check_base_path: '{{ local_os_password_vault_base }}'
|
||||
- vault_check_inc_vault_data: '{{ vault_data }}'
|
||||
- vault_check_fail_checks: '{{ local_os_password_vault_vars }}'
|
||||
|
||||
|
||||
|
||||
- name: 'Set fact: New OS local account password'
|
||||
no_log: 'true'
|
||||
ansible.builtin.set_fact:
|
||||
os_acc_pwd: '{{ vault_data.password }}'
|
||||
os_acc_salt: '{{ vault_data.password_salt }}'
|
||||
|
||||
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
- name: 'Set local OS account password'
|
||||
loop_control:
|
||||
loop_var: 'account'
|
||||
index_var: 'i'
|
||||
label: 'Set password for local account ''{{ account }}'''
|
||||
loop: '{{ reset_password_for_account }}'
|
||||
ansible.builtin.user:
|
||||
name: '{{ reset_password_for_account }}'
|
||||
password: '{{ os_acc_pwd | string | password_hash(''sha512'', os_acc_salt) }}'
|
||||
name: '{{ account }}'
|
||||
password: '{{ lookup(''hashi_vault'', ''secret=kv/data/settings/machines/'' + fqdn_reverse + ''/os/user/'' + account + '':password'') | string | password_hash(''sha512'', lookup(''hashi_vault'', ''secret=kv/data/settings/machines/'' + fqdn_reverse + ''/os/user/'' + account + '':password_salt'')) }}'
|
||||
update_password: 'always'
|
||||
|
@ -1 +1,2 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
- import_tasks: '40-local-os-password.yml'
|
||||
|
Loading…
x
Reference in New Issue
Block a user