From 9caa93c1cf17f592b9bccb503b39770f25247bcd Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 18 Jul 2014 18:23:48 -0400 Subject: [PATCH] Add note about useful quote filter. --- docsite/rst/guide_rolling_upgrade.rst | 8 ++++---- library/commands/shell | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docsite/rst/guide_rolling_upgrade.rst b/docsite/rst/guide_rolling_upgrade.rst index f730e8d789..c1b66b5c42 100644 --- a/docsite/rst/guide_rolling_upgrade.rst +++ b/docsite/rst/guide_rolling_upgrade.rst @@ -207,12 +207,12 @@ Here is the next part of the update play:: pre_tasks: - name: disable nagios alerts for this host webserver service - nagios: action=disable_alerts host={{ ansible_hostname }} services=webserver + nagios: action=disable_alerts host={{ inventory_hostname }} services=webserver delegate_to: "{{ item }}" with_items: groups.monitoring - name: disable the server in haproxy - shell: echo "disable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats + shell: echo "disable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats delegate_to: "{{ item }}" with_items: groups.lbservers @@ -233,12 +233,12 @@ Finally, in the ``post_tasks`` section, we reverse the changes to the Nagios con post_tasks: - name: Enable the server in haproxy - shell: echo "enable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats + shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats delegate_to: "{{ item }}" with_items: groups.lbservers - name: re-enable nagios alerts - nagios: action=enable_alerts host={{ ansible_hostname }} services=webserver + nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver delegate_to: "{{ item }}" with_items: groups.monitoring diff --git a/library/commands/shell b/library/commands/shell index 130abc6718..03e8f27c39 100644 --- a/library/commands/shell +++ b/library/commands/shell @@ -47,6 +47,9 @@ notes: playbooks will follow the trend of using M(command) unless M(shell) is explicitly required. When running ad-hoc commands, use your best judgement. + - To sanitize any variables passed to the shell module, you should use + "{{ var | quote }}" instead of just "{{ var }}" to make sure they don't include evil things like semicolons. + requirements: [ ] author: Michael DeHaan '''