Answers: <p>It turns out single quote works where double quote and backslash didn't.</p>
  
  <blockquote>
  <pre><code>- name: Enable rapid scan
    command: imunify360-agent config update '{"MALWARE_SCANNING"':' {"rapid_scan"':' true}}'
  </code></pre>
  </blockquote>
  
  <p>I learned that folding block scalar (>) is an easy alternative and a good way to avoid escaping.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-01-18T00:57:38.237Z
Answers: 2020-01-18T00:57:38.237Z
Answers: jwalker
Answers: <p>Assuming that you're already planning on executing each command in a separate task, you can just use a folding block scalar (<code>&gt;</code>). While these are typically used for multi-line strings since they replace newlines with a single space, a bonus is that they don't evaluate escape sequences, so nothing needs to be escaped.</p>
  
  <p>However, <code>&gt;</code> alone won't strip the trailing newline character which is where <code>-</code> comes in.</p>
  
  <pre><code>- name: Enable rapid scan
    command: &gt;-
      imunify360-agent config update '{"MALWARE_SCANNING": {"rapid_scan": true}}'
  
  - name: Cleanup scan schedule
    command: &gt;-
      imunify360-agent config update '{"MALWARE_SCANNING": {"default_action": "cleanup"}, "MALWARE_SCAN_SCHEDULE":{"interval": "week"}}'
  
  - name: Enable scan inotify
    command: &gt;-
      imunify360-agent config update '{"MALWARE_SCANNING": {"enable_scan_inotify": true}}'
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-01-17T03:05:28.473Z
Answers: 2020-01-17T03:05:28.473Z
Answers: jconnell
Body: <p>How can I use Ansible to run the following CloudLinux Imunify360 commands properly on CloudLinux 7 (similar to CentOS7)?
  I tried different ways to "escape" the colons in the commands and it doesn't run properly, even when a YAML syntax checker showed it's correct.</p>
  
  <pre><code>imunify360-agent config update '{"MALWARE_SCANNING": {"rapid_scan": true}}'
  imunify360-agent config update '{"MALWARE_SCANNING": {"default_action": "cleanup"}, "MALWARE_SCAN_SCHEDULE":{"interval": "week"}}'
  imunify360-agent config update '{"MALWARE_SCANNING": {"enable_scan_inotify": true}}'
  </code></pre>
  
  <p>from:
  <a href="https://blog.imunify360.com/new-default-settings-for-imunify360" rel="nofollow noreferrer">https://blog.imunify360.com/new-default-settings-for-imunify360</a></p>
  
  <p>Note: Imunify360 has a free trial.</p>
  
Tags: <ansible><linux><security>
Title: How to run Ansible command to update imunify360 settings
UserDisplayName: jwalker
ThreadText: # How to run Ansible command to update imunify360 settings
  
  (Asked by: username_0 on 2020-01-16)
  
  How can I use Ansible to run the following CloudLinux Imunify360 commands properly on CloudLinux 7 (similar to CentOS7)?
  I tried different ways to "escape" the colons in the commands and it doesn't run properly, even when a YAML syntax checker showed it's correct.
  
  ```
  imunify360-agent config update '{"MALWARE_SCANNING": {"rapid_scan": true}}'
  imunify360-agent config update '{"MALWARE_SCANNING": {"default_action": "cleanup"}, "MALWARE_SCAN_SCHEDULE":{"interval": "week"}}'
  imunify360-agent config update '{"MALWARE_SCANNING": {"enable_scan_inotify": true}}'
  
  ```
  
  from:
  <https://blog.imunify360.com/new-default-settings-for-imunify360>
  
  Note: Imunify360 has a free trial.
  
  **Tags:** ansible, linux, security
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-01-18. Score: 1 | Accepted answer
  
  It turns out single quote works where double quote and backslash didn't.
  
  > ```
  > - name: Enable rapid scan
  >   command: imunify360-agent config update '{"MALWARE_SCANNING"':' {"rapid_scan"':' true}}'
  >
  > ```
  
  I learned that folding block scalar (>) is an easy alternative and a good way to avoid escaping.
  
  
  ---
  
  ### Answer by username_1 on 2020-01-17. Score: 0
  
  Assuming that you're already planning on executing each command in a separate task, you can just use a folding block scalar (`>`). While these are typically used for multi-line strings since they replace newlines with a single space, a bonus is that they don't evaluate escape sequences, so nothing needs to be escaped.
  
  However, `>` alone won't strip the trailing newline character which is where `-` comes in.
  
  ```
  - name: Enable rapid scan
    command: >-
      imunify360-agent config update '{"MALWARE_SCANNING": {"rapid_scan": true}}'
  
  - name: Cleanup scan schedule
    command: >-
      imunify360-agent config update '{"MALWARE_SCANNING": {"default_action": "cleanup"}, "MALWARE_SCAN_SCHEDULE":{"interval": "week"}}'
  
  - name: Enable scan inotify
    command: >-
      imunify360-agent config update '{"MALWARE_SCANNING": {"enable_scan_inotify": true}}'
  
  ```
  
  
  ---
  
  