From 5c42e7a297e38b80aed8515fc26d26c3657714b1 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Thu, 1 Dec 2022 08:53:46 +0200 Subject: [PATCH] Get configuration file from puppet --- tasks/configure.yml | 77 ++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index e0b7201..0135061 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,28 +1,4 @@ --- -- name: Ensure puppet server master section is configured - ini_file: - path: /etc/puppetlabs/puppet/puppet.conf - section: master - option: "{{ item.key }}" - value: "{{ item.value }}" - mode: '0644' - backup: true - create: true - loop: "{{ puppet_master_config | dict2items }}" - notify: 'Restart puppetserver' - -- name: Ensure puppet server server section is configured - ini_file: - path: /etc/puppetlabs/puppet/puppet.conf - section: server - option: "{{ item.key }}" - value: "{{ item.value }}" - mode: '0644' - backup: true - create: true - loop: "{{ puppet_server_config | dict2items }}" - notify: 'Restart puppetserver' - - name: Find puppetserver command shell: which puppetserver | awk '{print($1)}' | true register: which_puppetserver @@ -59,11 +35,53 @@ msg: "Puppet command couldn't be found" when: which_puppet.stdout == "" +- name: Get puppet configuration file + shell: "{{ which_puppet.stdout }} config print config" + register: puppet_config_file_result + +- name: Set variable for Puppet configuration file + set_facts: + puppet_config_file: "{{ puppet_config_file_result.stdout }}" + +- name: Ensure puppet server master section is configured + ini_file: + path: "{{ puppet_config_file }}" + section: master + option: "{{ item.key }}" + value: "{{ item.value }}" + mode: '0644' + backup: true + create: true + loop: "{{ puppet_master_config | dict2items }}" + notify: 'Restart puppetserver' + +- name: Ensure puppet server server section is configured + ini_file: + path: "{{ puppet_config_file }}" + section: server + option: "{{ item.key }}" + value: "{{ item.value }}" + mode: '0644' + backup: true + create: true + loop: "{{ puppet_server_config | dict2items }}" + notify: 'Restart puppetserver' + - name: Configure CA server - shell: "{{ which_puppet.stdout }} config set ca_server {{ puppet_server_name }}" + ini_file: + path: "{{ puppet_config_file }}" + section: master + option: ca_server + value: "{{ puppet_server_name }}" +# shell: "{{ which_puppet.stdout }} config set ca_server {{ puppet_server_name }}" - name: Configure autosign server - shell: "{{ which_puppet.stdout }} config set autosign true" + ini_file: + path: "{{ puppet_config_file }}" + section: master + option: autosign + value: "true" +# shell: "{{ which_puppet.stdout }} config set autosign true" - name: Check if puppet code folder exists stat: @@ -139,6 +157,13 @@ dest: /etc/puppetlabs/puppet/prometheus.yaml backup: yes +- name: Configure puppet reports to prometheus + ini_file: + path: "{{ puppet_config_file }}" + section: master + option: reports + value: prometheus + - name: Ensure hiera-eyaml is installed shell: "{{ which_puppetserver.stdout }} gem install hiera-eyaml" args: