I apologize if this isn't an strictly an ansible problem, but I'm
attempting to run a command like the following which works when run
directly on the server in bash but fails when I try running via ansible.
- name: write commit to history
shell: "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml' ]] && { echo
'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml' >>
/app/psoft/install_logs/deployment_version_history.log; }"
output:
fatal: [net12204]: FAILED! => {"changed": true, "cmd": "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml' ]] && { echo
'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml' >>
/app/psoft/install_logs/deployment_version_history.log; }", "delta":
"0:00:00.006239", "end": "2016-07-26 16:58:47.826353", "failed": true,
"rc": 1, "start": "2016-07-26 16:58:47.820114", "stderr": "", "stdout": "",
"stdout_lines": [], "warnings": []}
I've tried the following variations without any luck:
shell: "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
\'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml\' ]] && { echo
\'81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml\' >>
/app/psoft/install_logs/deployment_version_history.log }"
shell: "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
''81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml'' ]] && { echo
''81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml'' >>
/app/psoft/install_logs/deployment_version_history.log }"
shell: "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
\"81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml\" ]] && { echo
\"81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml\" >>
/app/psoft/install_logs/deployment_version_history.log }"
This is two ' ' together instead of a double quote.
shell: "[[ $(tail -1
/app/psoft/install_logs/deployment_version_history.log) !=
''81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml'' ]] && { echo
''81cdc80ec7fdb0201e00fe2f8767b10ec136c687 peoplesoft.yml'' >>
/app/psoft/install_logs/deployment_version_history.log }"
The full explanation of what i'm trying to do is create a log with the
history of ansible plays run and their version in git that have been run
against the target application. In the full script the commit hash will be
coming from a register variable in a previous step, but i can't even get a
basic case to run with all the competing special characters. The command is
supposed to look at a log file and compare the last entry to the current
entry to be written and if they're not the same, to add the entry to the
end of the file. I tried doing this more simply with lineinfile but it
would only write if the line didn't exist somewhere else in the file(which
is not what i want).
Thanks in advance for any advice/help given.
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e0ee862b-9cc2-4a40-ab65-53dfc978cb72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.