markotitel |
12-05-2013 07:28 AM |
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:
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?
|