Alright. My thought would be to register the master key as a fact in one play:

register:  some_confluent_value

And you set the environment variable on the next play that needs it.

- name: some confluent operation
  command: do something
  environment:
    CONFLUENT_SECURITY_MASTER_KEY: "{{ some_confluent_value }}"
  register: output
  changed_when: output.rc = 0


—
Rilindo Foster - Cloud Reliability Architect


> On Mar 28, 2022, at 11:32 AM, Arundhati Bhende 
> <[email protected]> wrote:
> 
> Yes.  But the value will be different on each of the target machines and can 
> be determined after the copy  tasks are executed
>  
> From: <[email protected]> on behalf of Rilindo Foster 
> <[email protected]>
> Reply-To: "[email protected]" 
> <[email protected]>
> Date: Monday, March 28, 2022 at 10:59 AM
> To: "[email protected]" <[email protected]>
> Subject: Re: [Ext] [ansible-project] How to set-up playbook level Environment 
> variable after a few tasks
>  
> So you are saying that you want:
>  
> - CONFLUENT_SECURITY_MASTER_KEY be set?
> - That value be persistent through the remainder of the playbook run?
>  
> —
> Rilindo Foster - Cloud Reliability Architect
> 
> 
> 
>> On Mar 26, 2022, at 9:57 PM, Arundhati Bhende 
>> <[email protected] <mailto:[email protected]>> 
>> wrote:
>>  
>> 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 [email protected] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CBF647EC-2D0F-4C25-82DD-E5D14A55FB7F%40prudential.com
>>  
>> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCBF647EC-2D0F-4C25-82DD-E5D14A55FB7F%2540prudential.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Carundhati.bhende%40prudential.com%7Ce6d2328aa77145e1331a08da10cb509c%7Cd8fde2f5939242608a030ad01f4746e9%7C0%7C0%7C637840763983257832%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=g%2FMF7WEHYp6UoDUYcHoWHD%2FIRVDa99YyXlz0bsKsfF4%3D&reserved=0>.
> 
>  
> 
> 
>> 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. 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/47C58C8A-F1C1-47D5-A942-07E2F924C1F5%40nextcapital.com
>  
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F47C58C8A-F1C1-47D5-A942-07E2F924C1F5%2540nextcapital.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Carundhati.bhende%40prudential.com%7Ce6d2328aa77145e1331a08da10cb509c%7Cd8fde2f5939242608a030ad01f4746e9%7C0%7C0%7C637840763983257832%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=0vrTLKCA%2FtgUPjyd0saPgDfDfzDXp1exga%2F%2FoR23m%2BI%3D&reserved=0>.
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/07593FE6-E8E9-41FC-99B7-95AF6FCCAC4D%40prudential.com
>  
> <https://groups.google.com/d/msgid/ansible-project/07593FE6-E8E9-41FC-99B7-95AF6FCCAC4D%40prudential.com?utm_medium=email&utm_source=footer>.


-- 
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. 

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/42EEBCB4-2506-4763-9EE3-349829DFC499%40nextcapital.com.

Reply via email to