Ansible Playbook: Get value from variable

The name of the pictureThe name of the pictureThe name of the pictureClash 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








share







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.























    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








    share







    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.





















      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








      share







      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





      share







      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.










      share







      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.








      share



      share






      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.

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Patrick is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          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



































          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














          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













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?