LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices

Reply
 
Search this Thread
Old 12-05-2013, 07:28 AM   #1
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 155

Rep: Reputation: 18
Vagrant+Ansible playbooks. How to use same playbook on non vagrant provision


Hi, I wanted to try Ansible as deployment tool and have some setup to use with Vagrant. Deployment of that devel VM is working, I wanted to use same playbook on barebone server by manually running
Quote:
ansible-playbook
. That ofcorse cannot work because I was using some setting in playbook that were specific to vagrant. Is it posibile to tell ansible to auto distinct which kind of box it is provisioning?

Here is my playbook file:

Code:
- hosts: main
  remote_user: vagrant
  sudo: yes
  vars:
    app_name: iom
    symfony_root: /vagrant
    locale: en_US.UTF-8
    timezone: UTC
  tasks:
    - name: Setup sudoers for vagrant
      lineinfile: dest=/etc/sudoers
                  regexp='^vagrant ALL=\(ALL\) NOPASSWD:ALL'
                  line="vagrant ALL=(ALL) NOPASSWD:ALL"
                  state=present
                  insertafter=EOF

    - name: Set default language
      template: src=templates/etc/locale.gen dest=/etc/locale.gen

    - name: Install locales
      command: locale-gen

    - name: set locale to {{ locale }}
      command: /usr/sbin/update-locale LANG={{ locale }} LC_ALL={{ locale }} LANGUAGE=en_US:en

    - name: set /etc/localtime to {{ timezone }}
      command: /bin/cp /usr/share/zoneinfo/{{ timezone }} /etc/localtime

    - name: set /etc/timezone to {{ timezone }}
      template: src=templates/timezone dest=/etc/timezone
      notify: update tzdata

    - name: Update apt repo
      action: apt update-cache=yes cache_valid_time=86400

    - name: Install packages
      action: apt name={{ item }} state=installed
      with_items:
        - curl
        - vim
        - git
        - python-apt
        - python-pycurl

    - name: Add key for dotdeb repo
      action: apt_key url='http://www.dotdeb.org/dotdeb.gpg' state=present
Some of this is irrelevant to Vagrant specific setup and also some more code is ommited.

How do you solve this issue? Do you make one extra playbook that you use for production provisioning?
 
Old 12-06-2013, 09:00 AM   #2
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 155

Original Poster
Rep: Reputation: 18
Let me answer myself

There is inventory file where I can define host: ip_address, after that in playbook define which host will do chosen provisioning scheme.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Using Salt Stack and Vagrant for Drupal Development LXer Syndicated Linux News 0 05-21-2013 02:30 AM
LXer: Vagrant 1.1 adds first paid plugin for VMware Fusion LXer Syndicated Linux News 0 03-18-2013 05:51 PM
LXer: Introducing Vagrant LXer Syndicated Linux News 0 11-14-2012 08:50 PM
Vagrant / guess additions of VM LukasH Linux - Newbie 3 07-26-2012 07:14 AM


All times are GMT -5. The time now is 01:48 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration