summaryrefslogtreecommitdiff
path: root/ansible-practice/system/13-playbook-create-update-user.yml
diff options
context:
space:
mode:
authorboom2 <blizzack@blizzack.com>2023-12-21 15:49:16 -0500
committerboom2 <blizzack@blizzack.com>2023-12-21 15:49:16 -0500
commit200680e7c8cbd6b4426c3ce232568b1e06446bde (patch)
treeb122f103cc4dce8cea078c20dac107612399640e /ansible-practice/system/13-playbook-create-update-user.yml
parenta21b2f4bb64bd0f633d8a6a15f27a73103df70c0 (diff)
- renamed playbook to follow convention
-- add /etc/rc.d/rc.M in 'fetch file playbook' for future clamav playbook
Diffstat (limited to 'ansible-practice/system/13-playbook-create-update-user.yml')
-rw-r--r--ansible-practice/system/13-playbook-create-update-user.yml42
1 files changed, 42 insertions, 0 deletions
diff --git a/ansible-practice/system/13-playbook-create-update-user.yml b/ansible-practice/system/13-playbook-create-update-user.yml
new file mode 100644
index 0000000..b00af34
--- /dev/null
+++ b/ansible-practice/system/13-playbook-create-update-user.yml
@@ -0,0 +1,42 @@
+#
+# https://www.howtouselinux.com/post/create-user-with-ansible
+# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html
+# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html
+# https://docs.ansible.com/ansible/latest/collections/community/crypto/openssh_keypair_module.html
+# https://www.codesandnotes.be/2020/01/13/generate-ssh-keys-using-ansible/
+#
+---
+- name: "13 - custom ansible - create/update user"
+ hosts: dev
+ become: yes # Run tasks with root/sudo privileges
+ vars:
+ username: testuser1
+ password: mypassword
+ passphrase: one two three
+
+ tasks:
+ - name: create user
+ ansible.builtin.user:
+ name: "{{ username }}"
+ password: "{{ password | password_hash('sha512') }}" # encrypted password
+ state: present # ensure the user is present
+ createhome: true # create the users home directory
+ shell: /bin/bash
+ group: users # slackware default
+ groups: audio,cdrom,floppy,input,lp,netdev,plugdev,power,scanner,video,wheel
+ generate_ssh_key: true
+ ssh_key_type: ed25519
+ ssh_key_passphrase: "{{ passphrase }}"
+
+#
+# received the following when running this playbook:
+#
+# TASK [create user] *************************************************
+#
+# [DEPRECATION WARNING]: Encryption using the Python crypt module is
+# deprecated. The Python crypt module is deprecated and will be removed
+# from Python 3.13. Install the passlib library for continued encryption
+# functionality. This feature will be removed in version
+# 2.17. Deprecation warnings can be disabled by setting
+# deprecation_warnings=False in ansible.cfg.
+#