Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Create your Orchestration Galaxy With Ansible

gerardocepeda
September 08, 2014

Create your Orchestration Galaxy With Ansible

This presentation shows you how to create your own space to share Ansible roles across your company or private team using Ansible, Gitlab, Vagrant, VirtualBox and Librarian-Ansible.

Given at DevOps Montreal on Sept 8th, 2014.
Slide about the future added after Michael DeHaan's (Ansible's CTO) feedback.

gerardocepeda

September 08, 2014
Tweet

Other Decks in Technology

Transcript

  1. What is Ansible? « Ansible is a radically simple IT

    automation platform that makes your applications and systems easier to deploy. » -  https://github.com/ansible/ansible It does not require agents on remote hosts. It use native SSH.
  2. What is the best way to reuse Ansible content? Roles

    « …they allow you to focus more on the big picture and only dive down into the details when needed.. » -  http://docs.ansible.com/playbooks_roles.html#introduction
  3. « … And in the image of the Great Magic

    have we wrought our world»
  4. How Ansible Galaxy works?   1.  Download the roles you

    like 2.  Write simple playbooks to assemble all the roles together (including your own)
  5. The recipe   •  Ansible >= 1.4.2 (ansible-galaxy CLI) • 

    Gitlab (we’ll reuse a role from the Galaxy) •  Vagrant •  Virtualbox •  Librarian-Ansible
  6. Gitlab « Self hosted Git Management application. » « GitLab

    offers git repository management, code reviews, issue tracking, activity feeds, wikis»    
  7. Vagrant and VirtualBox « Vagrant provides easy to configure, reproducible,

    and portable work environments »   « VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use »  
  8. Gitlab Installation:     Create  the  playbook:      

            >  ansible-­‐galaxy  install  geerlingguy.gitlab   -­‐-­‐-­‐   #  file:  site.yml   -­‐  hosts:  gitlab-­‐local      roles:      -­‐  role:  "geerlingguy.gitlab"          sudo:  yes          gitlab_external_url:  "https://gitlab.local/"  
  9. Vagrantfile   #  file:  Vagrantfile  (extract)   Vagrant.configure(VAGRANTFILE_API_VERSION)  do  |config|

         config.vm.box  =  "trusty64"      #  …  Somme  other  stuf  here        #  Gitlab  service  server.      config.vm.define  "gitlab-­‐service"  do  |service|          service.vm.hostname  =  "gitlab.local"            service.vm.network  "private_network",  ip:  "192.168.33.17"            config.vm.provider  "virtualbox"  do  |vb|          #  …  Somme  other  stuf  like  memory  and  cpus  config  here  (remcomended  2048M  RAM  and  2cpus)          end            service.vm.provision  "ansible"  do  |ansible|              ansible.inventory_path  =  "myinventory"              ansible.playbook  =  "site.yml"              ansible.limit  =  "gitlab-­‐local"                    end      end   end    
  10. Vagrant – Create your Gitlab Server   Create the Gitlab

    Server: >  vagrant  up  gitlab-­‐service  
  11. Create your own roles Create the role scaffold: Create the

    playbook and push to Gitlab:       >  ansible-­‐galaxy  init  ansible-­‐role-­‐hello-­‐devops-­‐montreal   -­‐-­‐-­‐   #  file:  taks/main.yml   #  task  file  for  ansible-­‐role-­‐hello-­‐devops-­‐montreal   -­‐  name:  Say  hello  to  the  audience      debug:  msg=  "Hello!  DevOps  Montreal"  
  12. One AnsibleFile to rule them all! Structure of the AnsibleFile:

    #!/usr/bin/env  ruby   #^syntax  detection     site  "https://galaxy.ansible.com/api/v1"     role  "kunik.deploy-­‐upstart-­‐scripts"     role  "pgolm.ansible-­‐playbook-­‐monit",      github:  "pgolm/ansible-­‐playbook-­‐monit  »     role  "pgolm.ansible-­‐playbook-­‐monit",        git:  "[email protected]:pgolm/ansible-­‐playbook-­‐monit.git"     role  "ansible-­‐role-­‐nagios-­‐nrpe-­‐server",      ">=0.0.0",      path:  "./roles/ansible-­‐role-­‐nagios-­‐nrpe-­‐server"  
  13. Integrate your roles Create the Ansiblefile: Install the external roles:

    Create an ansible.cfg file: [defaults]   #  By  default  the  same  directory  that  AnsibleFile   roles_path  =  librarian_roles     role  "my-­‐own-­‐galaxy.hello-­‐devops-­‐mtl",      "1.0.0",      git:  "[email protected]:my-­‐own-­‐galaxy/ansible-­‐role-­‐hello-­‐devops-­‐montreal.git"   >  librarian-­‐ansible  install  
  14. Create the playbook              

      -­‐-­‐-­‐   #  file:  site.yml   -­‐  hosts:  local-­‐dev      roles:            -­‐  {  role:  my-­‐own-­‐galaxy.hello-­‐devops-­‐mtl  }  
  15. Demo time! >              

                             
  16. The future – Coming in Ansible 1.8! >  ansible-­‐galaxy  install

     -­‐r  requirements.yml   -­‐-­‐-­‐   #  file:  requirements.yml   #  from  galaxy   -­‐  src:  yatesr.timezone     #  from  github   -­‐  src:  https://github.com/bennojoy/nginx     #  from  a  webserver,  where  the  role  is  packaged  in  a  tar.gz   -­‐  src:  https://some.webserver.example.com/files/master.tar.gz      name:  http-­‐role     #  …  And  More!    
  17. Further Reading The code of this presentation: -  https://github.com/gcporras/own-galaxy-gitlab-server - 

    https://github.com/gcporras/ansible-role-hello-devops-montreal -  https://github.com/gcporras/own-galaxy-role-reuse-example Ansible 1.8 Role Requirements Files: -  http://docs.ansible.com/galaxy.html#advanced-control-over-role-requirements-files Ansible: -  http://docs.ansible.com -  http://galaxy.ansible.com -  http://probablyfine.co.uk/2014/03/27/how-to-write-an-ansible-role-for-ansible-galaxy/ Gitlab: -  https://galaxy.ansible.com/list#/roles/516 Librarian-ansible: -  https://github.com/bcoe/librarian-ansible Ansible-role-manager: -  https://github.com/mirskytech/ansible-role-manager