From charlesreid1

(Created page with "Walkthrough of creating an Ansible playbook for yeti. a) found pyenv playbook online. use this. b) flailing with vagrant. =Setup= Before we start, we want to have the fol...")
 
Line 13: Line 13:
* Vagrantfile for running vagrant machines for testing our playbook
* Vagrantfile for running vagrant machines for testing our playbook


This page will cover the remainder, which consists of:
==Vagrantfile==


* Creating the playbook directory structure
Here we give a Vagrantfile that will start three separate nodes. This is important to test yeti's ability to handle multiple machines.
* Utilizing existing roles on ansible galaxy
 
* Test playbook
'''<code>Vagrantfile</code>:'''
 
<pre>
VAGRANTFILE_API_VERSION = "2"
 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
  # Use the same key for each machine
  config.ssh.insert_key = false
 
  config.vm.define "vagrant1" do |vagrant1|
    vagrant1.vm.box = "ubuntu/xenial64"
    vagrant1.vm.network "forwarded_port", guest: 80, host: 8877
    vagrant1.vm.network "forwarded_port", guest: 443, host: 7443
  end
  config.vm.define "vagrant2" do |vagrant2|
    vagrant2.vm.box = "ubuntu/xenial64"
    vagrant2.vm.network "forwarded_port", guest: 80, host: 8878
    vagrant2.vm.network "forwarded_port", guest: 443, host: 7444
  end
  config.vm.define "vagrant3" do |vagrant3|
    vagrant3.vm.box = "ubuntu/xenial64"
    vagrant3.vm.network "forwarded_port", guest: 80, host: 8879
    vagrant3.vm.network "forwarded_port", guest: 443, host: 7445
  end
end
</pre>
 
Also see [[Ansible/Vagrant]].
 
==Inventory file==
 
Info for the inventory file (port numbers) can be obtained with:
 
<pre>
vagrant ssh-config
</pre>
 
The corresponding inventory file looks like this:
 
<pre>
[servers]
vagrant1 ansible_host=127.0.0.1 ansible_port=2222
vagrant2 ansible_host=127.0.0.1 ansible_port=2201
vagrant3 ansible_host=127.0.0.1 ansible_port=2202
</pre>

Revision as of 05:27, 10 December 2018

Walkthrough of creating an Ansible playbook for yeti.

a) found pyenv playbook online. use this.

b) flailing with vagrant.


Setup

Before we start, we want to have the following:

Vagrantfile

Here we give a Vagrantfile that will start three separate nodes. This is important to test yeti's ability to handle multiple machines.

Vagrantfile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  # Use the same key for each machine
  config.ssh.insert_key = false

  config.vm.define "vagrant1" do |vagrant1|
    vagrant1.vm.box = "ubuntu/xenial64"
    vagrant1.vm.network "forwarded_port", guest: 80, host: 8877
    vagrant1.vm.network "forwarded_port", guest: 443, host: 7443
  end
  config.vm.define "vagrant2" do |vagrant2|
    vagrant2.vm.box = "ubuntu/xenial64"
    vagrant2.vm.network "forwarded_port", guest: 80, host: 8878
    vagrant2.vm.network "forwarded_port", guest: 443, host: 7444
  end
  config.vm.define "vagrant3" do |vagrant3|
    vagrant3.vm.box = "ubuntu/xenial64"
    vagrant3.vm.network "forwarded_port", guest: 80, host: 8879
    vagrant3.vm.network "forwarded_port", guest: 443, host: 7445
  end
end

Also see Ansible/Vagrant.

Inventory file

Info for the inventory file (port numbers) can be obtained with:

vagrant ssh-config

The corresponding inventory file looks like this:

[servers]
vagrant1 ansible_host=127.0.0.1 ansible_port=2222
vagrant2 ansible_host=127.0.0.1 ansible_port=2201
vagrant3 ansible_host=127.0.0.1 ansible_port=2202