Code Share
FreeIPA — Create User via Ansible
Ansible task to create a FreeIPA user with standard attributes and group membership.
Ansible
freeipaansibleidentityldap
Description
Creates a user in FreeIPA with standard attributes, sets a temporary password, and adds to specified groups. Requires the freeipa.ansible_freeipa collection.
Prerequisites
ansible-galaxy collection install freeipa.ansible_freeipa
Playbook
---
- name: Create FreeIPA User
hosts: ipaserver
become: false
vars:
ipaadmin_password: ""
ipaadmin_principal: admin
user:
login: jdoe
first: John
last: Doe
email: jdoe@example.com
groups:
- sysadmins
- vpn-users
tasks:
- name: Ensure user exists
freeipa.ansible_freeipa.ipauser:
ipaadmin_password: ""
ipaadmin_principal: ""
name: ""
first: ""
last: ""
email: ""
password: "ChangeMe123!"
update_password: on_create
state: present
- name: Add user to groups
freeipa.ansible_freeipa.ipagroup:
ipaadmin_password: ""
ipaadmin_principal: ""
name: ""
action: member
user:
- ""
state: present
loop: ""
Notes
- Store
vault_ipa_admin_passwordin Ansible Vault - User will be forced to change password on first login
- Requires SSH/API access to the IPA server host