I need to set a playbook level Environment variable after executing some tasks. The variable needs to be set-up separately on each server by reading a file on the server – I am told I should use slurp, but do not know how to use it to define playbook level environment variable.
Can someone help?
This is the current version of the playbook
- name: server properties
hosts: kafka_broker
vars:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
ansible_host_key_checking: false
date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M%S') }}"
copy_to_dest: "/export/home/kafusr/kafka/secrets"
server_props_loc: "/etc/kafka"
secrets_props_loc: "{{ server_props_loc }}/secrets"
environment:
CONFLUENT_SECURITY_MASTER_KEY: "”
tasks:
- name: Create a directory if it does not exist
file:
path: "{{ copy_to_dest }}"
state: directory
mode: '0755'
- name: Find files from "{{ server_props_loc }}"
find:
paths: /etc/kafka/
patterns: "server.properties*"
# ... the rest of the task
register: etc_kafka_server_props
- name: Find files from "{{ secrets_props_loc }}"
find:
paths: /etc/kafka/secrets
patterns: "*"
# ... the rest of the task
register: etc_kafka_secrets_props
- name: Copy the files
copy:
src: "{{ item.path }}"
dest: "{{ copy_to_dest }}"
remote_src: yes
loop: "{{ etc_kafka_server_props.files + etc_kafka_secrets_props.files }}"
Need help is setting up CONFLUENT_SECURITY_MASTER_KEY after the copy files task to read the a file from secrets directory using slurp, and have it avaibale at playbook level
Regards
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CBF647EC-2D0F-4C25-82DD-E5D14A55FB7F%40prudential.com.
This email and its attachments are confidential and may be privileged. Any unauthorized use or disclosure is prohibited. If you receive this email in error, please notify the sender and permanently delete the original without forwarding, making any copies or disclosing its contents. NextCapital is a brand name representing NextCapital Group, Inc. and its subsidiaries, NextCapital Software, Inc. and NextCapital Advisers, Inc.
Yes. But the value will be different on each of the target machines and can be determined after the copy tasks are executed
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/47C58C8A-F1C1-47D5-A942-07E2F924C1F5%40nextcapital.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/07593FE6-E8E9-41FC-99B7-95AF6FCCAC4D%40prudential.com.
But, this would mean, I have to set it as environment in all the subsequent plays, right? Not at the playbook level?
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/42EEBCB4-2506-4763-9EE3-349829DFC499%40nextcapital.com.