Ansible: Adding Ansible users and SSH without SSH keys

I wanted to add a page that makes getting Ansible online a bit easier. I am assuming that you have Ubuntu 20.04 installed and have SSH already working on it.

  1. Adding Ansible user to target machine
    1. Log into target server using existing user over SSH
    2. Change to root user
      1. sudo su -
    3. Add new user
      1. adduser <user>
      2. Follow wizard
    4. Change user access for sudo
      1. usermod -aG sudo <user> 
    5. Change to that user
      1. su <user>
      2. cd ~
    6. Generate SSH key
      1. ssh-keygen
  2. Adding user data to Ansible host file. I am assuming you have already set up your Ansible host file.
    1. Edit the host file
      1. sudo nano /etc/ansible/hosts
    2. Add this block to the bottom of the file.
      1. [all:vars]

        ansible_python_interpreter=/usr/bin/python3

        ansible_user=<user>

        ansible_ssh_pass=<user password>

    3. Test
      1. ansible -m ping <target host IP> 
  3. Profit

SideNote: This is best used only in secure environments as anyone with access to this server can do bad things on your servers. USE WITH CAUTION!!!

Comments

Popular posts from this blog

Using MBR with older hardware and VMware ESXi 6.0 and 6.5

Getting Rancher LongHorn to work with RancherOS on vSphere