I have a couple of different machine types that all need to have the official postgres APT repo defined for them in order to be able to apt-get install
the right version of tools. These different machines all need to share the following:
---
- name: add postgres repo key
sudo: yes
apt_key: url=http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc
id=ACCC4CF8
- name: add postgres repo
sudo: yes
apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main'
I have two roles that depend on it, my nagios
role (needs to do a bunch of psql work) and my postgres-base
role. It'd be fantastic if I could have both of those roles somehow include the same file / tasks above.
Right now I have created a separate role for the tasks, called it postgres-repo
and I'm using ansible's role dependencies to make sure that both the roles above run postgres-repo
before executing.
This is their meta/main.yml
:
---
dependencies:
- postgres-repo
Is that the best I can do? Is there a more lightweight approach than making a separate role?