Using Ansible Playbooks - ezra-buckingham/terry-the-terraformer Wiki

Ansible Inventory Format

Terry can build all types of servers. At runtime, Terry will dynamically generate an Ansible inventory file which will then be used to populate the playbook varaibles. The stucture of the inventory is as follows:

all:
  children:
    bare:
      hosts:
        18.217.237.1:
          ansible_user: admin
          domain_map: []
          name: bare1
          nebula_ip: 10.0.0.4
          provider: aws
          uuid: f8e2b589-2859-40d4-af2c-f8cafd87ed25
    categorize:
      hosts: {}
    lighthouse:
      hosts:
        167.71.252.123:
          am_lighthouse: true
          ansible_user: root
          name: documentation-lighthouse1
          nebula_ip: 10.0.0.1
          provider: digitalocean
          uuid: f3a50782-8dc7-4cd2-b0c7-7b876ee8f35e
    redirector:
      hosts:
        167.71.252.99:
          ansible_user: root
          domain_map:
          - dermain.example.com
          name: teamserver1-dns-redir
          nebula_ip: 10.0.0.3
          provider: digitalocean
          redirector_type: dns
          uuid: db44df6c-76d6-4199-b37a-f8bcc3a08c52
    teamserver:
      hosts:
        3.15.28.195:
          ansible_user: admin
          containers:
            sliver:
              name: sliver
              redirector_ip: null
          domain_map: []
          name: teamserver1
          nebula_ip: 10.0.0.2
          provider: aws
          uuid: 48875e2c-8e66-4f42-8e17-45ea5680a796
  vars:
    lighthouse_nebula_ip: 10.0.0.1
    lighthouse_public_ip: 1.1.1.1
    main_email: [email protected]
    nebula: true
    op_directory: /path/to/operation_dir
    team:
      ezra:
        public_ip: 8.8.8.8
        public_key: ssh-rsa AAAAB3NzaC1yc...< TRUNCATED >
        user: ezrab

Using the inventory structure above, all servers are configured using Ansible. In order for the playbooks to work, a few assumptions have been made:

  • SSH is available (from your network, so if deploying to a private cloud that is behind a firewall, make sure you can route to that IP address)
  • The host is running Debian

Running a Playbook

In order to configure a "base" server with all the "base" configuration needed for all the other scripts to run, you can run the command below:

ansible-playbook ./playbooks/prep-all-systems.yml -i ./path/to/inventory_file

Additional configuration is made to each of the specific types of servers.