Skip to content

Creating a new admin user to backends

Repository: attracs-linux-playbooks admin_users/create_admin_user.yml:

#- hosts: attracs-billing-vm, attracs-devops-3 
- hosts: all
  vars:
    # set user name and path here or use command line variables, for example:
    #admin_user: aasiala
    #ssh_public_key: "~/.ssh/aasiala-backends.pub"
    admin_user: 
    ssh_public_key: ""

  tasks:

    - name: Create user
      user: 
        name: '{{ admin_user }}'
...

Edit the admin user file like so: 1. Change hosts to match a single host instead of all, just in case something goes wrong.

- hosts: all
- hosts: attracs-devops-1
  1. Change admin_user to what you'd like your admin user to be named:
admin_user: 
admin_user: "miro_salo_aholadigital_com"
  1. Change ssh_public_key to the SSH key you will use to connect to backends:
ssh_public_key: ""
ssh_public_key: "miro_adi_id_ed25519.pub"

Run the playbook like so: ansible-playbook admin_users/create_admin_user.yml --private-key ~/.ssh/attracs-backend The --private-key file can be found from 1Password if you do not have it already.

You should get something like this upon successful run:

[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [attracs-devops-1] ***************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [attracs-devops-1]

TASK [Create user] *************************************************************************************************************************************************************************************************
changed: [attracs-devops-1]

TASK [Make sure we have a 'admins' group] **************************************************************************************************************************************************************************
ok: [attracs-devops-1]

TASK [Allow 'admins' group to have passwordless sudo] **************************************************************************************************************************************************************
ok: [attracs-devops-1]

TASK [Add user to admins group] ************************************************************************************************************************************************************************************
changed: [attracs-devops-1]

TASK [Set up authorized keys for the deployer user] ****************************************************************************************************************************************************************
changed: [attracs-devops-1]

PLAY RECAP *********************************************************************************************************************************************************************************************************
attracs-devops-1      : ok=6    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

You should be fine now with changing the hosts to all and running the rest of the backends.