Skip to content

Instantly share code, notes, and snippets.

@maxim
Created June 10, 2014 18:11
Show Gist options
  • Save maxim/ab56347451e11bc86161 to your computer and use it in GitHub Desktop.
Save maxim/ab56347451e11bc86161 to your computer and use it in GitHub Desktop.
ansible task for ensuring postgresql extension exists without skipping or perpetual "changed"
- name: ensure postgresql hstore extension is created
sudo: yes
sudo_user: postgres
shell: "psql {{ postgresql_database }} -c 'CREATE EXTENSION hstore;'"
register: psql_result
failed_when: >
psql_result.rc != 0 and ("already exists" not in psql_result.stderr)
changed_when: "psql_result.rc == 0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment