stdout just md5sum and file name

13 views
Skip to first unread message

Simon Tomazic

unread,
Oct 27, 2014, 1:11:49 PM10/27/14
to ansible...@googlegroups.com
I would like to md5sum two conf files server.xml and server.xml_latest in the same folder on two instances on remote server. How can I get stdout just "b9b82f9ad039e9d1b4c0233dbacf3934  /opt/tomcat-instance/fep21/conf/server.xml" or somehow check if config file have same md4sum and stdout on screen like Files have same md5sum hash or Files have different md5sum hash!!!

I have playbook thah look like that.

  vars:
      tc_instances:
         - tc_inst_name: tc20
         - tc_inst_name: tc21

  tasks:

       - name: md5 -> /opt/tomcat-instance/[TC_INST]/conf/server.xml
         command: md5sum /opt/tomcat-instance/{{ item.tc_inst_name }}/conf/server.xml
         with_items: tc_instances
         register: md5_server_xml

       - debug: msg={{ item.stdout }}
         with_items: md5_server_xml.results

       - name: md5 -> /opt/tomcat-instance/[TC_INST]/conf/server.xml_latest
         command: md5sum /opt/tomcat-instance/{{ item.tc_inst_name }}/conf/server.xml_latest
         with_items: tc_instances
         register: md5_server_xml_latest

       - debug: msg={{ item.stdout }}
         with_items: md5_server_xml_latest.results


and stdout on console like thaht

TASK: [debug msg={{ item.stdout }}] *******************************************
ok: [192.168.2.150] => (item={u'stdout': u'b9b82f9ad039e9d1b4c0233dbacf3934  /opt/tomcat-instance/tc21/conf/server.xml', u'changed': True, u'end': u'2014-10-27 13:41:39.234463', 'item': {'tc_inst_name': 'tc21'}, u              'cmd': [u'md5sum', u'/opt/tomcat-instance/tc21/conf/server.xml'], u'rc': 0, u'start': u'2014-10-27 13:41:39.219446', u'stderr': u'', u'delta': u'0:00:00.015017', 'invocation': {'module_name': u'command', 'module_ar              gs': u'md5sum /opt/tomcat-instance/tc21/conf/server.xml'}}) => {
    "item": {
        "changed": true,
        "cmd": [
            "md5sum",
            "/opt/tomcat-instance/tc21/conf/server.xml"
        ],
        "delta": "0:00:00.015017",
        "end": "2014-10-27 13:41:39.234463",
        "invocation": {
            "module_args": "md5sum /opt/tomcat-instance/tc21/conf/server.xml",
            "module_name": "command"
        },
        "item": {
            "tc_inst_name": "tc21"
        },
        "rc": 0,
        "start": "2014-10-27 13:41:39.219446",
        "stderr": "",
        "stdout": "b9b82f9ad039e9d1b4c0233dbacf3934  /opt/tomcat-instance/fep21/conf/server.xml"
    },
    "msg": "b9b82f9ad039e9d1b4c0233dbacf3934"
}

Thank you for help and suggestions.
Reply all
Reply to author
Forward
0 new messages