Skip to content

Instantly share code, notes, and snippets.

@shurane
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shurane/42e7b774f4d9db433e3f to your computer and use it in GitHub Desktop.
Save shurane/42e7b774f4d9db433e3f to your computer and use it in GitHub Desktop.

Delete a folder before recreating it with ansible-playbook

[defaults]
hostfile=hosts.ini
---
- hosts: machine
vars:
app_path: /tmp/dingus/
env_user: vagrant
tasks:
- name: create inodes
file: >
dest={{ item.dest }}
state={{ item.state }}
owner={{ env_user }}
group={{ env_user }}
mode={{ item.mode }}
recurse={{ item.recurse }}
with_items:
- { dest: "{{ app_path }}", state: absent, mode: "0755", recurse: False } # delete file
- { dest: "{{ app_path }}", state: directory, mode: "0755", recurse: True }
#- file: >
#dest=/tmp/bower_components/
#state=absent
#- copy: >
#src=bower_components/
#dest=/tmp/bower_components/
#- synchronize: >
#src=bower_components/
#dest=/tmp/bower_components/
#rsync_opts='-e "ssh -p 2222"'
# TODO
#- [ ] pm2 kill
#- [ ] file + copy module
#- [ ] otherwise synchronize module
[machine]
localhost ansible_ssh_port=2222 ansible_ssh_user=vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "256"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment