Delete old databases

26 views
Skip to first unread message

Yoann DAVID

unread,
Apr 22, 2014, 12:28:37 PM4/22/14
to ansible...@googlegroups.com
I want to create a playbook to create but also delete databases that are not anymore in my configuration file.

Lets take an example, I have a variable listing database to create :

db:
  - foo
  - bar

First run DB foo and bar are created, if I remove bar from my list, when I run ansible bar is always in my server.

I would find a solution to address the deletion of a previously added db but not available anymore.

Somewhere something like this playbook (for users) : https://github.com/jurgenhaas/ansible-user-management

Any idea to deal with this problem ?
How do you deal with resources added then removed to delete them on server ?

Create a temporary playbook to explicitly remove the resources ?

James Cammarata

unread,
Apr 22, 2014, 2:37:54 PM4/22/14
to ansible...@googlegroups.com
You might want to look at http://docs.ansible.com/playbooks_loops.html#looping-over-hashes, where you could create a dictionary structure like:

my_dbs:
  db1:
    state: present
  db2:
    state: absent

And your task could look like this:

- name: add/remove databases
  whatever_db_module: name={{item.key}} state={{item.value.state}}
  with_dict: my_dbs



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a4c54e48-61a1-4aef-a5cd-588cb09b512a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages