How to get started - scottgoetz/ansible GitHub Wiki

Install Ansible and dependencies

  1. sudo apt install ansible
  2. sudo apt install whois
  3. Add Client names and IPs to Ansible "hosts" file:
    • Must match names under the "hosts" area in ansible scripts: i.e. mail, core, redirector, drone
    • sudo vi /etc/ansible/hosts

Pre setup if your client is not configured with an unprivileged user using SSH keys:

  1. Generate and record password hash for the new unprivilged user use in .yml files:
    • mkpasswd -m sha-512
  2. Disable host key checking:
    • sudo vi /etc/ansible/ansible.cfg
  3. sudo apt-get install sshpass
  4. Generate ssh keypairs for Clients, annotate paths for .yml files:
    • ssh-keygen
  • If this does not apply to you, modify secureSetup.yml appropriately

Initialize playbook variables

  • Modify variables in the "vars" section of each Ansible script
  • Data that needs to be modified is contained between angle brackets (e.g. <variable_name>)
  • If you are running scripts in series to build a certain infrastructure concept (i.e. phishing server + mail server + web redirector), you will not know all of the variables up front as some of the required information is dependent on a prior script executing. For example, ghostPhish.yml requires the SSL certs generated by webRedirector.yml

Review playbooks before execution

  • Read through each playbook you are executing and ensure that you understand what each playbook is doing
  • You may want to remove certain Ansible tasks that do not apply to your situation

How to execute playbooks

  • Run initial secureSetup.yml Ansible script to configure Clients in a secure state:
    • sudo ansible-playbook --ask-pass -u root secureSetup.yml
  • Run secondary Ansible scripts to configure Client for various purposes:
    • sudo ansible-playbook -u <Client_unprivileged_user_name> <script_name>.yml --key-file <path/sshkey_rsa> --ask-become-pass

For when you rebuild a Client and need to delete old keys

  • sudo ssh-keygen -f "/root/.ssh/known_hosts" -R clientIp