Ansible Playbook: Get value from variable

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm writing my first ansible playbook right now. That's what I have so far.
---
- hosts: kolumbus become: yes
 tasks:
 - name: Copy RPM
 copy:
 src: " item "
 dest: /tmp
 with_fileglob:
 - /opt/omd/versions/default/share/check_mk/agents/check-mk-agent-*.noarch.rpm
 register: copied_file
 - debug: var=copied_file
The output of debug is:
TASK [debug] **********************************************************************************************************************************************************************************
ok: [kolumbus] => 
 "copied_file": 
 "changed": false,
 "msg": "All items completed",
 "results": [
 
 "_ansible_ignore_errors": null,
 "_ansible_item_result": true,
 "_ansible_no_log": false,
 "_ansible_parsed": true,
 "changed": false,
 "checksum": "55ae455adc639f9cfca738683b5955f32e78d2db",
 "dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "diff": 
 "after": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 ,
 "before": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 
 ,
 "failed": false,
 "gid": 0,
 "group": "root",
 "invocation": 
 "module_args": 
 "attributes": null,
 "backup": null,
 "content": null,
 "delimiter": null,
 "dest": "/tmp",
 "diff_peek": null,
 "directory_mode": null,
 "follow": false,
 "force": false,
 "group": null,
 "mode": null,
 "original_basename": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "owner": null,
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "recurse": false,
 "regexp": null,
 "remote_src": null,
 "selevel": null,
 "serole": null,
 "setype": null,
 "seuser": null,
 "src": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "state": "file",
 "unsafe_writes": null,
 "validate": null
 
 ,
 "item": "/opt/omd/versions/default/share/check_mk/agents/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "mode": "0644",
 "owner": "root",
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "secontext": "unconfined_u:object_r:user_home_t:s0",
 "size": 32768,
 "state": "file",
 "uid": 0
 
 ]
 
How can I get the value
"dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
to keep working with it?
For example like this:
 - name: Install check_mk
 yum:
 name: " copied_file.results.dest "
 state: present
variable ansible
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
I'm writing my first ansible playbook right now. That's what I have so far.
---
- hosts: kolumbus become: yes
 tasks:
 - name: Copy RPM
 copy:
 src: " item "
 dest: /tmp
 with_fileglob:
 - /opt/omd/versions/default/share/check_mk/agents/check-mk-agent-*.noarch.rpm
 register: copied_file
 - debug: var=copied_file
The output of debug is:
TASK [debug] **********************************************************************************************************************************************************************************
ok: [kolumbus] => 
 "copied_file": 
 "changed": false,
 "msg": "All items completed",
 "results": [
 
 "_ansible_ignore_errors": null,
 "_ansible_item_result": true,
 "_ansible_no_log": false,
 "_ansible_parsed": true,
 "changed": false,
 "checksum": "55ae455adc639f9cfca738683b5955f32e78d2db",
 "dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "diff": 
 "after": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 ,
 "before": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 
 ,
 "failed": false,
 "gid": 0,
 "group": "root",
 "invocation": 
 "module_args": 
 "attributes": null,
 "backup": null,
 "content": null,
 "delimiter": null,
 "dest": "/tmp",
 "diff_peek": null,
 "directory_mode": null,
 "follow": false,
 "force": false,
 "group": null,
 "mode": null,
 "original_basename": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "owner": null,
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "recurse": false,
 "regexp": null,
 "remote_src": null,
 "selevel": null,
 "serole": null,
 "setype": null,
 "seuser": null,
 "src": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "state": "file",
 "unsafe_writes": null,
 "validate": null
 
 ,
 "item": "/opt/omd/versions/default/share/check_mk/agents/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "mode": "0644",
 "owner": "root",
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "secontext": "unconfined_u:object_r:user_home_t:s0",
 "size": 32768,
 "state": "file",
 "uid": 0
 
 ]
 
How can I get the value
"dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
to keep working with it?
For example like this:
 - name: Install check_mk
 yum:
 name: " copied_file.results.dest "
 state: present
variable ansible
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm writing my first ansible playbook right now. That's what I have so far.
---
- hosts: kolumbus become: yes
 tasks:
 - name: Copy RPM
 copy:
 src: " item "
 dest: /tmp
 with_fileglob:
 - /opt/omd/versions/default/share/check_mk/agents/check-mk-agent-*.noarch.rpm
 register: copied_file
 - debug: var=copied_file
The output of debug is:
TASK [debug] **********************************************************************************************************************************************************************************
ok: [kolumbus] => 
 "copied_file": 
 "changed": false,
 "msg": "All items completed",
 "results": [
 
 "_ansible_ignore_errors": null,
 "_ansible_item_result": true,
 "_ansible_no_log": false,
 "_ansible_parsed": true,
 "changed": false,
 "checksum": "55ae455adc639f9cfca738683b5955f32e78d2db",
 "dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "diff": 
 "after": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 ,
 "before": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 
 ,
 "failed": false,
 "gid": 0,
 "group": "root",
 "invocation": 
 "module_args": 
 "attributes": null,
 "backup": null,
 "content": null,
 "delimiter": null,
 "dest": "/tmp",
 "diff_peek": null,
 "directory_mode": null,
 "follow": false,
 "force": false,
 "group": null,
 "mode": null,
 "original_basename": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "owner": null,
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "recurse": false,
 "regexp": null,
 "remote_src": null,
 "selevel": null,
 "serole": null,
 "setype": null,
 "seuser": null,
 "src": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "state": "file",
 "unsafe_writes": null,
 "validate": null
 
 ,
 "item": "/opt/omd/versions/default/share/check_mk/agents/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "mode": "0644",
 "owner": "root",
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "secontext": "unconfined_u:object_r:user_home_t:s0",
 "size": 32768,
 "state": "file",
 "uid": 0
 
 ]
 
How can I get the value
"dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
to keep working with it?
For example like this:
 - name: Install check_mk
 yum:
 name: " copied_file.results.dest "
 state: present
variable ansible
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm writing my first ansible playbook right now. That's what I have so far.
---
- hosts: kolumbus become: yes
 tasks:
 - name: Copy RPM
 copy:
 src: " item "
 dest: /tmp
 with_fileglob:
 - /opt/omd/versions/default/share/check_mk/agents/check-mk-agent-*.noarch.rpm
 register: copied_file
 - debug: var=copied_file
The output of debug is:
TASK [debug] **********************************************************************************************************************************************************************************
ok: [kolumbus] => 
 "copied_file": 
 "changed": false,
 "msg": "All items completed",
 "results": [
 
 "_ansible_ignore_errors": null,
 "_ansible_item_result": true,
 "_ansible_no_log": false,
 "_ansible_parsed": true,
 "changed": false,
 "checksum": "55ae455adc639f9cfca738683b5955f32e78d2db",
 "dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "diff": 
 "after": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 ,
 "before": 
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm"
 
 ,
 "failed": false,
 "gid": 0,
 "group": "root",
 "invocation": 
 "module_args": 
 "attributes": null,
 "backup": null,
 "content": null,
 "delimiter": null,
 "dest": "/tmp",
 "diff_peek": null,
 "directory_mode": null,
 "follow": false,
 "force": false,
 "group": null,
 "mode": null,
 "original_basename": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "owner": null,
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "recurse": false,
 "regexp": null,
 "remote_src": null,
 "selevel": null,
 "serole": null,
 "setype": null,
 "seuser": null,
 "src": "check-mk-agent-1.5.0p5-1.noarch.rpm",
 "state": "file",
 "unsafe_writes": null,
 "validate": null
 
 ,
 "item": "/opt/omd/versions/default/share/check_mk/agents/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "mode": "0644",
 "owner": "root",
 "path": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
 "secontext": "unconfined_u:object_r:user_home_t:s0",
 "size": 32768,
 "state": "file",
 "uid": 0
 
 ]
 
How can I get the value
"dest": "/tmp/check-mk-agent-1.5.0p5-1.noarch.rpm",
to keep working with it?
For example like this:
 - name: Install check_mk
 yum:
 name: " copied_file.results.dest "
 state: present
variable ansible
variable ansible
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 3 mins ago
Patrick
1
1
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Patrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Patrick is a new contributor. Be nice, and check out our Code of Conduct.
 
draft saved
draft discarded
Patrick is a new contributor. Be nice, and check out our Code of Conduct.
Patrick is a new contributor. Be nice, and check out our Code of Conduct.
Patrick is a new contributor. Be nice, and check out our Code of Conduct.
 
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477666%2fansible-playbook-get-value-from-variable%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password