--- /dev/null
+---
+
+- name: 'Adjust custom puppet facts for customer data.'
+ hosts: '{{ target }}'
+
+ tasks:
+ - name: 'What is going to happen?'
+ debug: "var={{ item }}"
+ with_items:
+ - target
+ - project
+ - customer_yaml_file
+
+ - name: "Get file stats of {{ customer_yaml_file }} ..."
+ stat:
+ path: "{{ customer_yaml_file }}"
+ ignore_errors: True
+ changed_when: False
+ register: customer_yfile_stat
+
+ - name: "Get current configured customer in {{ customer_yaml_file }} ..."
+ shell: "if test -f {{ customer_yaml_file }} ; then cat {{ customer_yaml_file }} | grep '^customer:' | sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'; fi"
+ ignore_errors: True
+ changed_when: False
+ register: cur_customer
+
+ - name: "Get current configured project in {{ customer_yaml_file }} ..."
+ shell: "if test -f {{ customer_yaml_file }} ; then cat {{ customer_yaml_file }} | grep '^project:' | sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'; fi"
+ ignore_errors: True
+ changed_when: False
+ register: cur_project
+
+ - name: "Set project in in {{ customer_yaml_file }}, if necessary ..."
+ block:
+
+ - name: "Save project {{ cur_customer.stdout }} in {{ customer_yaml_file }} ..."
+ shell: "echo -e \"---\ncustomer: {{ cur_customer.stdout }}\nproject: {{ cur_customer.stdout }}\" > {{ test_customer_yaml_file }}"
+
+ when: cur_project.stdout == ''
+
+ - name: "Set permissions of file {{ customer_yaml_file }} ..."
+ file:
+ path: "{{ customer_yaml_file }}"
+ owner: 'root'
+ group: 'root'
+ mode: 0644
+ when: customer_yfile_stat.stat.exists == true
+
stage: 'live'
live-search01-spk.spk.pixelpark.net:
stage: 'live'
- live-search01-spk.spk.pixelpark.net:
- stage: 'live'
live-search02-spk.spk.pixelpark.net:
stage: 'live'
live-search03-spk.spk.pixelpark.net:
stage: 'stage'
vars:
project: 'spk-saas-mysql'
+
+ vars:
+ customer_yaml_file: '/etc/puppetlabs/facter/facts.d/customer.yaml'
+ test_customer_yaml_file: '/tmp/customer.yaml'
+