summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-25 17:43:26 +0000
committerGerrit Code Review <review@openstack.org>2018-04-25 17:43:26 +0000
commitd5dbfc3a62d0e12cf47dc723463a85e5ea693a8b (patch)
tree926dd0985d03f8d7968e50a1a8de74dd525aa66a
parent6adb0c7632bfc8370587a11eee2ddaa1461b8019 (diff)
parent4d64868882038dd846e5128d70d3eaccf2d0ec59 (diff)
Merge "Don't hardcode puppet-3-specific config paths"
-rw-r--r--defaults/main.yml4
-rw-r--r--library/puppet_get_hiera_file_list2
-rw-r--r--tasks/config.yml23
-rw-r--r--tasks/main.yml69
-rw-r--r--templates/environment.conf.j22
-rw-r--r--templates/puppet.conf.j26
6 files changed, 90 insertions, 16 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index 9411169..9e7acd0 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -10,8 +10,8 @@ puppet_server: puppet
10certname: "{{ ansible_fqdn }}" 10certname: "{{ ansible_fqdn }}"
11puppet_data_binding_terminus: hiera 11puppet_data_binding_terminus: hiera
12puppet_reports: store 12puppet_reports: store
13puppet_basemodulepath: '$confdir/modules' 13puppet_basemodulepath: ''
14puppet_environmentpath: '$confdir/environments' 14puppet_environmentpath: ''
15puppet_hiera_datadir: '/opt/system-config/' 15puppet_hiera_datadir: '/opt/system-config/'
16puppet_environment_basedir: '/opt/system-config/' 16puppet_environment_basedir: '/opt/system-config/'
17puppet_environment: production 17puppet_environment: production
diff --git a/library/puppet_get_hiera_file_list b/library/puppet_get_hiera_file_list
index d00cff3..79dbe54 100644
--- a/library/puppet_get_hiera_file_list
+++ b/library/puppet_get_hiera_file_list
@@ -59,7 +59,7 @@ def main():
59 for path in paths: 59 for path in paths:
60 full_path = os.path.join(p['location'], path) 60 full_path = os.path.join(p['location'], path)
61 if os.path.exists(full_path): 61 if os.path.exists(full_path):
62 good_paths.append(full_path) 62 good_paths.append(path)
63 63
64 module.exit_json(paths=good_paths) 64 module.exit_json(paths=good_paths)
65 65
diff --git a/tasks/config.yml b/tasks/config.yml
index 5e6f272..e7fb593 100644
--- a/tasks/config.yml
+++ b/tasks/config.yml
@@ -1,9 +1,22 @@
1--- 1---
2- name: Set puppet conf dir
3 set_fact:
4 puppet_confdir: "{{ '/etc/puppet' if puppet_version == '3' else '/etc/puppetlabs/puppet' }}"
5
6- name: Set puppet code dir
7 set_fact:
8 puppet_codedir: "{{ '/etc/puppet' if puppet_version == '3' else '/etc/puppetlabs/code' }}"
9
10- name: Enable puppet environments explicitly for puppet 3
11 set_fact:
12 puppet_environmentpath: '$confdir/environments'
13 when: puppet_version == '3' and puppet_environmentpath == ''
14
2# Create our config 15# Create our config
3- name: Create puppet.conf from template 16- name: Create puppet.conf from template
4 template: 17 template:
5 src: "puppet.conf.j2" 18 src: "puppet.conf.j2"
6 dest: "/etc/puppet/puppet.conf" 19 dest: "{{ puppet_confdir }}/puppet.conf"
7 owner: root 20 owner: root
8 group: root 21 group: root
9 mode: 0644 22 mode: 0644
@@ -11,14 +24,14 @@
11- name: Create hiera.yaml from template 24- name: Create hiera.yaml from template
12 template: 25 template:
13 src: "hiera.yaml.j2" 26 src: "hiera.yaml.j2"
14 dest: "/etc/puppet/hiera.yaml" 27 dest: "{{ puppet_confdir }}/hiera.yaml"
15 owner: root 28 owner: root
16 group: root 29 group: root
17 mode: 0644 30 mode: 0644
18 31
19- name: symlink hiera config files together 32- name: symlink hiera config files together
20 file: 33 file:
21 src: "/etc/puppet/hiera.yaml" 34 src: "{{ puppet_confdir }}/hiera.yaml"
22 dest: "/etc/hiera.yaml" 35 dest: "/etc/hiera.yaml"
23 owner: root 36 owner: root
24 group: root 37 group: root
@@ -27,7 +40,7 @@
27 40
28- name: create environment directory 41- name: create environment directory
29 file: 42 file:
30 path: "/etc/puppet/environments/{{ puppet_environment }}" 43 path: "{{ puppet_codedir }}/environments/{{ puppet_environment }}"
31 state: directory 44 state: directory
32 owner: root 45 owner: root
33 group: root 46 group: root
@@ -37,7 +50,7 @@
37- name: create environment.conf from template 50- name: create environment.conf from template
38 template: 51 template:
39 src: "environment.conf.j2" 52 src: "environment.conf.j2"
40 dest: "/etc/puppet/environments/{{ puppet_environment }}/environment.conf" 53 dest: "{{ puppet_codedir }}/environments/{{ puppet_environment }}/environment.conf"
41 owner: root 54 owner: root
42 group: root 55 group: root
43 mode: 0644 56 mode: 0644
diff --git a/tasks/main.yml b/tasks/main.yml
index 3041cb0..3882a10 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,9 +1,45 @@
1--- 1---
2- name: Get management server puppet version
3 shell:
4 cmd: "PATH=$PATH:/opt/puppetlabs/bin puppet --version | cut -d '.' -f 1"
5 delegate_to: localhost
6 register: mgmt_puppet_version
7
8- name: Set management server puppet version fact
9 set_fact:
10 mgmt_puppet_version: "{{ mgmt_puppet_version.stdout }}"
11
12- name: Sanity check management server puppet version
13 fail: "Unsupported puppet version {{ mgmt_puppet_version }}"
14 when: (mgmt_puppet_version != '3' and mgmt_puppet_version != '4')
15
16- name: Get puppet version
17 shell:
18 cmd: "PATH=$PATH:/opt/puppetlabs/bin puppet --version | cut -d '.' -f 1"
19 register: puppet_version
20
21- name: Set puppet version fact
22 set_fact:
23 puppet_version: "{{ puppet_version.stdout }}"
24
25- name: Sanity check puppet version
26 fail: "Unsupported puppet version {{ puppet_version }}"
27 when: (puppet_version != '3' and puppet_version != '4')
28
2- block: 29- block:
30 - name: Set management server hieradata var
31 set_fact:
32 mgmt_hieradata: "{{ '/etc/puppet/hieradata' + puppet_environment if mgmt_puppet_version == '3' else '/etc/puppetlabs/code/environments/' + puppet_environment + '/hieradata' }}"
33 delegate_to: localhost
34
35 - name: Set hieradata var
36 set_fact:
37 hieradata: "{{ '/etc/puppet/hieradata' + puppet_environment if puppet_version == '3' else '/etc/puppetlabs/code/environments/' + puppet_environment + '/hieradata' }}"
38
3 - name: ensure hiera directory 39 - name: ensure hiera directory
4 file: 40 file:
5 state: directory 41 state: directory
6 path: "{{ hieradata }}/{{ puppet_environment }}/{{ item }}" 42 path: "{{ hieradata }}//{{ item }}"
7 owner: root 43 owner: root
8 group: root 44 group: root
9 mode: 0700 45 mode: 0700
@@ -15,14 +51,14 @@
15 puppet_get_hiera_file_list: 51 puppet_get_hiera_file_list:
16 fqdn: "{{ ansible_fqdn }}" 52 fqdn: "{{ ansible_fqdn }}"
17 groups: "{{ hostvars[inventory_hostname].group_names }}" 53 groups: "{{ hostvars[inventory_hostname].group_names }}"
18 location: "{{ hieradata }}/{{ puppet_environment }}" 54 location: "{{ hieradata }}"
19 delegate_to: localhost 55 delegate_to: localhost
20 register: hiera_file_paths 56 register: hiera_file_paths
21 57
22 - name: copy hiera files 58 - name: copy hiera files
23 copy: 59 copy:
24 src: "{{ item }}" 60 src: "{{ mgmt_hieradata + '/' + item }}"
25 dest: "{{ item }}" 61 dest: "{{ hieradata + '/' item }}"
26 mode: 0600 62 mode: 0600
27 with_items: "{{ hiera_file_paths.paths|default() }}" 63 with_items: "{{ hiera_file_paths.paths|default() }}"
28 64
@@ -41,10 +77,31 @@
41 state: link 77 state: link
42 when: copy_hieradata 78 when: copy_hieradata
43 79
80 - name: Set management server puppet module dir to user-defined path
81 set_fact:
82 mgmt_puppet_module_dir: "{{ puppet_basemodulepath }}"
83 when: puppet_basemodulepath != ''
84
85 - name: Set management server puppet module dir
86 set_fact:
87 mgmt_puppet_module_dir: "{{ '/etc/puppet/modules' if mgmt_puppet_version == '3' else '/etc/puppetlabs/code/modules' }}"
88 delegate_to: localhost
89 when: mgmt_puppet_module_dir is not defined
90
91 - name: Set puppet module dir to user-defined path
92 set_fact:
93 puppet_module_dir: "{{ puppet_basemodulepath }}"
94 when: puppet_basemodulepath != ''
95
96 - name: Set puppet module dir
97 set_fact:
98 puppet_module_dir: "{{ '/etc/puppet' if puppet_version == '3' else '/etc/puppetlabs/code' }}"
99 when: puppet_module_dir is not defined
100
44 - name: copy system puppet modules 101 - name: copy system puppet modules
45 synchronize: 102 synchronize:
46 src: /etc/puppet/modules 103 src: "{{ mgmt_puppet_module_dir }}"
47 dest: /etc/puppet 104 dest: "{{ puppet_module_dir }}"
48 105
49 when: 106 when:
50 - copy_puppet 107 - copy_puppet
diff --git a/templates/environment.conf.j2 b/templates/environment.conf.j2
index 7726473..c1e3a27 100644
--- a/templates/environment.conf.j2
+++ b/templates/environment.conf.j2
@@ -1 +1 @@
modulepath = '{{ puppet_basemodulepath }}:{{ puppet_environment_basedir }}{{ puppet_environment }}/modules' modulepath = {{ puppet_basemodulepath if puppet_basemodulepath != '' else '$basemodulepath' }}:$environmentpath/{{ puppet_environment }}/modules:{{ puppet_environment_basedir if puppet_environment_basedir != '' else '$environmentpath' }}/{{ puppet_environment }}/modules
diff --git a/templates/puppet.conf.j2 b/templates/puppet.conf.j2
index 4e48051..ad41108 100644
--- a/templates/puppet.conf.j2
+++ b/templates/puppet.conf.j2
@@ -8,9 +8,13 @@ certname={{ certname }}
8pluginsync=true 8pluginsync=true
9data_binding_terminus={{ puppet_data_binding_terminus }} 9data_binding_terminus={{ puppet_data_binding_terminus }}
10reports={{ puppet_reports }} 10reports={{ puppet_reports }}
11environmenttimeout=0
12{% if puppet_basemodulepath != '' %}
11basemodulepath = {{ puppet_basemodulepath }} 13basemodulepath = {{ puppet_basemodulepath }}
14{% endif %}
15{% if puppet_environmentpath != '' %}
12environmentpath={{ puppet_environmentpath }} 16environmentpath={{ puppet_environmentpath }}
13environmenttimeout=0 17{% endif %}
14 18
15[master] 19[master]
16# These are needed when the puppetmaster is run by passenger 20# These are needed when the puppetmaster is run by passenger