Colleen Murphy 4d64868882 Don't hardcode puppet-3-specific config paths
This patch ensures that hiera data and puppet modules, and puppet config
are copied to the right directory depending on the current puppet
version. Since it's possible for the ansible management server and the
managed nodes to have different puppet versions, we need to account for
the possibility that the source and destination paths might be
different. We also don't need to hardcode the various config paths in
config or manage environments since we're using the defaults and
hardcoding them would make them incorrect for one or the other puppet
versions.

Change-Id: I164f91f9a7942e8c5f059652634ec1078ae41aae
2018-04-22 00:13:21 +02:00

58 lines
1.5 KiB
YAML

---
- name: Set puppet conf dir
set_fact:
puppet_confdir: "{{ '/etc/puppet' if puppet_version == '3' else '/etc/puppetlabs/puppet' }}"
- name: Set puppet code dir
set_fact:
puppet_codedir: "{{ '/etc/puppet' if puppet_version == '3' else '/etc/puppetlabs/code' }}"
- name: Enable puppet environments explicitly for puppet 3
set_fact:
puppet_environmentpath: '$confdir/environments'
when: puppet_version == '3' and puppet_environmentpath == ''
# Create our config
- name: Create puppet.conf from template
template:
src: "puppet.conf.j2"
dest: "{{ puppet_confdir }}/puppet.conf"
owner: root
group: root
mode: 0644
- name: Create hiera.yaml from template
template:
src: "hiera.yaml.j2"
dest: "{{ puppet_confdir }}/hiera.yaml"
owner: root
group: root
mode: 0644
- name: symlink hiera config files together
file:
src: "{{ puppet_confdir }}/hiera.yaml"
dest: "/etc/hiera.yaml"
owner: root
group: root
state: link
force: yes
- name: create environment directory
file:
path: "{{ puppet_codedir }}/environments/{{ puppet_environment }}"
state: directory
owner: root
group: root
mode: 0755
when: puppet_environment is defined
- name: create environment.conf from template
template:
src: "environment.conf.j2"
dest: "{{ puppet_codedir }}/environments/{{ puppet_environment }}/environment.conf"
owner: root
group: root
mode: 0644
when: puppet_environment is defined