Skip to main content

Creating an Ansible Controller

Basic requirements, test with any mixture of the following basic Ansible commands.

ansible <host> -m ping
ansible <hostgroup> -m ping
ansible <hostgroup> -m ping -u <user>
ansible <host> -m ping --private-key=/home/user/.ssh/key
ansible <host> -m ping -u <user> --private-key=/home/user/.ssh/key

 

2 hosts

  1. controller
    1. has ansible
    2. create ssh key as the ansible user
      1. ssh-copy-id <worker>
      2. should be able to ssh with no password - ssh <workstation> as ansible user
        1. If the above does not work, create /home/USER/.ssh/config and add IdentityFile /path/to/Private.key, this will pass the key automatically when connecting as USER.
        2. Ensure the host you are connecting to has the connecting key within the ~/.ssh/authorized_keys file.
        3. restart sshd.service - sudo systemctl restart sshd.service
  2. worker
    1. has ansible
    2. has a known password, but can sudo without one.
      1. <user> ALL=(ALL) ALL NOPASSWD:ALL within sudoers
    3.