setup_base_user¶
Creates the operational Linux user that every other playbook/role runs as
(via become_user/ansible_ssh_user), with passwordless sudo, and
authorizes the control machine's SSH key for it. Part of first-time server
bootstrap only — not something you re-run per app.
What it does¶
- Creates the user
username(/bin/bashshell) if it doesn't exist. - Adds a
NOPASSWD: ALLsudoers entry for that user (validated withvisudo -cfbefore writing). - Authorizes the control machine's local
~/.ssh/id_rsa.pubas anauthorized_keyfor that user, so subsequent Ansible runs can connect asusernameover key-based SSH instead of the initial password/provided-user login.
Variables¶
| Variable | Required | Default | Description |
|---|---|---|---|
username |
yes | — | The operational Linux user to create (spigushe in every current playbook). |
Requirements¶
- Run as/with a user that already has root (
become: yes), typically the server's initial provisioning account (seeinitial.yml). - Expects
~/.ssh/id_rsa.pubto exist on the control machine running Ansible, not on the target host.
Example¶
# initial.yml
- hosts: all
become: true
vars:
username: spigushe
roles:
- role: setup_base_user