Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
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.


  Search this Thread
Old 12-05-2013, 08:28 AM   #1
Registered: Feb 2009
Location: Titel - Serbia
Posts: 181

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
. 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:

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

    - 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
        - curl
        - vim
        - git
        - python-apt
        - python-pycurl

    - name: Add key for dotdeb repo
      action: apt_key url='' 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, 10:00 AM   #2
Registered: Feb 2009
Location: Titel - Serbia
Posts: 181

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.


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 03:30 AM
LXer: Vagrant 1.1 adds first paid plugin for VMware Fusion LXer Syndicated Linux News 0 03-18-2013 06:51 PM
LXer: Introducing Vagrant LXer Syndicated Linux News 0 11-14-2012 09:50 PM
Vagrant / guess additions of VM LukasH Linux - Newbie 3 07-26-2012 08:14 AM > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 08:57 AM.

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