forked from cerc-io/testnet-ops
1.6 KiB
1.6 KiB
user-setup
Setup Ansible
To get started, follow the installation guide to setup ansible on your machine.
Setup a user
-
Create a new
hosts.inifile:cp ../hosts.example.ini hosts.ini -
Edit the
hosts.inifile to run the playbook on a remote machine:[deployment_host] <host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'- Replace
<host_name>with the desiredhostnameof the remote machine - Replace
<target_ip>with the IP address or hostname of the target machine - Replace
<ssh_user>withroot
- Replace
-
Verify that you are able to connect to the host using the following command:
ansible all -m ping -i hosts.ini # Expected output: # <host_name> | SUCCESS => { # "ansible_facts": { # "discovered_interpreter_python": "/usr/bin/python3.10" # }, # "changed": false, # "ping": "pong" # } -
Setup
user-vars.ymlusing the example filecp user-vars.example.yml user-vars.yml -
Edit the
user-vars.ymlfile:# name of the user you want to setup on the target host username: "" # password of the user you want to setup on the target host password: "" # path to the ssh key on your machine, eg: "/home/user/.ssh/id_rsa.pub" path_to_ssh_key: "" -
Execute the
setup-user.ymlAnsible playbook to create a user with passwordless sudo permissions:LANG=en_US.utf8 ansible-playbook setup-user.yml -i hosts.ini