#!/bin/bash
if $( command -v vim >/dev/null 2>&1 ); then
echo "vim is already installed."
else
apt-get install vim
fi
if $( grep -Fxq "filetype indent off" /etc/vim/vimrc ); then
echo "set filetype indent off is already in /etc/vim/vimrc."
else
echo "filetype indent off" >> /etc/vim/vimrc
# TODO: Do not continue if this fails.
fi
# TODO: Rollback if something fails.
Describe state
- name: ensure installed vim
apt: pkg={{ item }} state=installed
- name: add a string to the new file
lineinfile:
dest=/etc/vim/vimrc
line='filetype indent off'
state=present
Ansible
SSH-based
Client only (no server)
YAML configuration
Push
Supports more than setup and provisioning:
Application deployment
Remote command execution
Installation and setup (1 of 3)
# Map the ip addresses of the VMs in your /etc/hosts
192.168.101.10 db.local db
192.168.101.11 app1.local app1
192.168.101.12 app2.local app2
192.168.101.13 proxy.local proxy
Installation and setup (2 of 3)
#Prevent StrictHostKeyChecking by adding the following to ~/.ssh/config
Host db.local
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
User vagrant
LogLevel QUIET
Host app1.local
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
User vagrant
LogLevel QUIET
Host app2.local
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
User vagrant
LogLevel QUIET
Host proxy.local
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
User vagrant
LogLevel QUIET