Re: [ansible-project] Trick to remove a backslash liternal in Ansible?

2022-01-14 Thread Stefan Hornburg (Racke)

On 14/01/2022 16:17, Jibun no Kage wrote:

New to Ansible, having trouble doing the following:  shell command returns a "This 
is a test\u" string.  I can't seem to find a way to trim the '\u'.  Since it 
seem to be tricking to remove a backslash literal in Ansible?

The following would work in a shell command...
  cat /proc/device-tree/model | cut -d '\' -f1

But Ansible chokes on the '\'?  And even '\\'  does not work since cut command 
can't handle more than one char.  So the cut parsing trips or Ansible parsing 
trips.  A bit of a catch-22.

Figure there has to be an Ansible elegant way to do this?

Any help appreciated.


 - debug:
 msg: "{{ input | regex_replace('u', '') }}"
   vars:
 input: 'This is a test\u'

You might need *four* backslashes to get rid of the original backslash.

But you can get away with *two" by swapping the quotes:

 - debug:
 msg: '{{ input | regex_replace("\\u", "") }}'
   vars:
 input: 'This is a test\u'

Regards
Racke



--
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 
ansible-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a71e1eb3-4ddb-4461-bffd-1a3ea5004e2bn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/87f1ea8a-8d4b-3c3c-de2c-a611fa0cbe05%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Odd results from query of /proc/meminfo?

2022-01-14 Thread Stefan Hornburg (Racke)

On 14/01/2022 18:23, Jibun no Kage . wrote:

Odd results from query of /proc/meminfo?

When I do the following from shell...
# cat /proc/meminfo | grep MemTotal
MemTotal:    8087276 kB

But when I do the same via Ansible...
ok: [192.168.1.212] => {
     "msg": "Pi Memory Total: MemTotal: 957160 kB"
}



Why messing with the shell when the information is already present in the facts?

 - name: Show memory
  debug:
msg: "{{ ansible_memory_mb }}"

TASK [Show memory] *
ok: [bullseye-test-box] =>
  msg:
nocache:
  free: 828
  used: 1154
real:
  free: 82
  total: 1982
  used: 1900
swap:
  cached: 0
  free: 0
  total: 0
  used: 0

Regards
   Racke


Ansible Source...
     - name: Memory Total
   #shell: "cat /proc/meminfo | grep MemTotal | cut -d ':' -f2 | cut -d 'k' -f1 
| tr -d ' '"
   shell: "cat /proc/meminfo | grep MemTotal"
   register: m
   changed_when: False

     - name: Memory Total
   debug:
     msg: "Memory Total: {{ m.stdout }}"

Returned value is greater than physical memory size!




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/39e4a9c2-480d-d2c6-c1c7-4e77a7415b52%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


[ansible-project] Odd results from query of /proc/meminfo?

2022-01-14 Thread Jibun no Kage .

Odd results from query of /proc/meminfo?

When I do the following from shell...
# cat /proc/meminfo | grep MemTotal
MemTotal:    8087276 kB

But when I do the same via Ansible...
ok: [192.168.1.212] => {
    "msg": "Pi Memory Total: MemTotal: 957160 kB"
}

Ansible Source...
    - name: Memory Total
  #shell: "cat /proc/meminfo | grep MemTotal | cut -d ':' -f2 | cut 
-d 'k' -f1 | tr -d ' '"

  shell: "cat /proc/meminfo | grep MemTotal"
  register: m
  changed_when: False

    - name: Memory Total
  debug:
    msg: "Memory Total: {{ m.stdout }}"

Returned value is greater than physical memory size!

--
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/54f9a37e-9038-81b0-2650-eeb7ee212779%40gmail.com.


Re: [ansible-project] Email results , either failure or success

2022-01-14 Thread Brian Coca
for failures 
https://docs.ansible.com/ansible/latest/collections/community/general/mail_callback.html

for success 
https://docs.ansible.com/ansible/latest/collections/community/general/mail_module.html



-- 
--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7eJgNxzbpGUWQnGa4GXCygO5FOzPYooPYNoxpT7fYUviw%40mail.gmail.com.


[ansible-project] Email results , either failure or success

2022-01-14 Thread Nitrous
We have 3 playbooks, that all acheive different tasks when building a 
server.
Each playbook can have either a role in it or a module from collection.

How can I email result of when either a task fails in any of  3 playbooks ( 
this is when ansible quits, and I rerun my playbook again)  and, email me 
final result of when the whole build was successful only.

Hope I am making sense.

Thanks


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13b4e81e-6213-4459-b59e-911851e62e0en%40googlegroups.com.


[ansible-project] Trick to remove a backslash liternal in Ansible?

2022-01-14 Thread Jibun no Kage
New to Ansible, having trouble doing the following:  shell command returns 
a "This is a test\u" string.  I can't seem to find a way to trim the 
'\u'.  Since it seem to be tricking to remove a backslash literal in 
Ansible?

The following would work in a shell command...
 cat /proc/device-tree/model | cut -d '\' -f1

But Ansible chokes on the '\'?  And even '\\'  does not work since cut 
command can't handle more than one char.  So the cut parsing trips or 
Ansible parsing trips.  A bit of a catch-22.

Figure there has to be an Ansible elegant way to do this?

Any help appreciated.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a71e1eb3-4ddb-4461-bffd-1a3ea5004e2bn%40googlegroups.com.