Commit b47804ca81f02eb4701920e261b56904671047bd

Authored by Lars Tiede
1 parent 9d18e1b0

a bit more content, massaging

Showing 2 changed files with 16 additions and 3 deletions   Show diff stats
README.markdown
1 1 Utviklerlunsj: Ansible
2 2 ======================
3 3  
4   -The presentation is available as [keynote](presentation.key) and [pdf](presentation.pdf) files.
  4 +The presentation is available as a [keynote](presentation.key) or [pdf](presentation.pdf) file.
5 5  
6 6  
7 7 How to install the demo environment
... ... @@ -96,6 +96,19 @@ We have a minimal web app in the [webapp](webapp/) directory. We want to deploy
96 96  
97 97 The playbook in [deploy\_and\_run\_web\_app.yml](deploy_and_run_web_app.yml) does all of this.
98 98  
99   -The playbook contains two 'plays', i.e., sequences of tasks and role invocations that are applied to a set of hosts. In the first play, the playbook sets up the web app instances on all hosts in the 'app\_servers' group (as defined in the [inventory file](inventory/demo)). For this, we have a role '[runs\_web\_app](roles/runs_web_app)'. In it, its sequence of tasks is (per convenion) in [tasks/main.yml](roles/runs_web_app/tasks/main.yml). Files, templates and other role specific things can also be found in the role's directory. For this role, we just have one file in its 'files' subdirectory. Check out the Ansible documentation on [roles](http://docs.ansible.com/playbooks_roles.html#roles) for more details about what you can do with and inside roles.
  99 +The playbook contains two 'plays', i.e., sequences of tasks and role invocations that are applied to a set of hosts. In the first play, the playbook sets up the web app instances on all hosts in the 'app\_servers' group (as defined in the [inventory file](inventory/demo)). To do this on each host, we have a role '[runs\_web\_app](roles/runs_web_app)'. In it, its sequence of tasks is (per convention) in [tasks/main.yml](roles/runs_web_app/tasks/main.yml). Files, templates and other role specific things can also be found in the role's directory. For this role, we just have one file in its 'files' subdirectory. Check out the Ansible documentation on [roles](http://docs.ansible.com/playbooks_roles.html#roles) for more details about what you can do with and inside roles.
100 100  
101   -The second play of the playbook sets up the load balancer on all hosts in the 'load\_balancer' group. In our inventory, that group contains only one host. For running a simple load balancer, we have the role '[runs\_simple\_load\_balancer](roles/runs_simple_load_balancer)'. This role can be configured a bit through variables that are passed into it on invocation: on which hosts and ports does the app run that should be load-balanced. There is a template in the role ([the nginx config file snippet](roles/runs_simple_load_balancer/templates/sites-enabled/webapp.j2)) that uses these variables. Variables can also be used nearly anywhere else outside of templates; think of most of the playbook text content as template-able content. [Nearly everything is passed through the jinja2 templating engine that comes bundled with Ansible](http://docs.ansible.com/playbooks_variables.html#using-variables-about-jinja2).
  101 +The second play of the playbook sets up the load balancer on all hosts in the 'load\_balancer' group. In our inventory, that group contains only one host. For running a simple load balancer, we have the role '[runs\_simple\_load\_balancer](roles/runs_simple_load_balancer)'. This role can be configured a bit through variables that are passed into it on invocation: on which hosts and ports does the app run that should be load-balanced. There is a template in the role ([the nginx config file snippet](roles/runs_simple_load_balancer/templates/sites-enabled/webapp.j2)) that uses these variables. Variables can also be used nearly anywhere else outside of templates; think of most of the playbook text content as template-able content. Nearly everything is passed through the jinja2 templating engine that comes bundled with Ansible. Check the Ansible documentation on [variables and templating everywhere](http://docs.ansible.com/playbooks_variables.html#using-variables-about-jinja2) for more.
  102 +
  103 +
  104 +### 5. Play!
  105 +
  106 +Run the playbook:
  107 +
  108 + vagrant@demo-control:/vagrant$ ansible-playbook -i inventory/demo deploy_and_run_web_app.yml
  109 +
  110 +Point your browser to the IP that is shown at the end of the playbook output. Refresh the page a couple of times to see the load balancer in action.
  111 +
  112 +Now play around with the sources and playbooks and files as you wish. For example, change the inventory file so that you have only one host in the app\_servers group. Run the playbook again. See the difference? It is that easy now to change your infrastructure and update your app's configuration.
  113 +
  114 +Use Vagrant to your advantage while playing around. If you want to "wipe" target2, for example, just run "vagrant destroy target2" and then "vagrant up target2" on your machine (in the directory with our Vagrantfile). When you do this, target2 will get a new SSH host key. You will have to deal with that on the control VM. How to do this is left as an exercise to the reader ;) (approaches include disabling strict host key checking or removing the host key from /home/vagrant/.ssh/known\_hosts).
... ...
presentation.key
No preview for this file type