[ansible-project] ansible with_sequence result message hide

2020-03-12 Thread 이승준
I want to hide the result message of with_sequence
-
*My task playbook  : *
- name: Alarm check debug: msg="Alarm check" when: '"{{ item }} alarms 
currently active" in HOST_MGMT1.stdout' register: result_alarm 
with_sequence: start=0 end=10
--
*Content of HOST MGMT1 : *
Routing Engine status:
  Slot 0:
Current state  Master
Temperature 34 degrees C / 93 degrees F
DRAM  11676 MB (12288 MB installed)
Memory utilization   9 percent
5 sec CPU utilization:
  User   2 percent
  Background 0 percent
  Kernel 2 percent
  Interrupt  0 percent
  Idle  96 percent
1 min CPU utilization:
  User   1 percent
  Background 0 percent
  Kernel 1 percent
  Interrupt  0 percent
  Idle  98 percent
5 min CPU utilization:
  User   1 percent
  Background 0 percent
  Kernel 1 percent
  Interrupt  0 percent
  Idle  98 percent
15 min CPU utilization:
  User   1 percent
  Background 0 percent
  Kernel 1 percent
  Interrupt  0 percent
  Idle  98 percent
Model  RE-QFX10008
Serial ID  BCAB0322
Start time 2020-03-05 16:01:35 KST
Uptime 7 days, 21 hours, 3 minutes, 25 seconds
Last reboot reason 0x2000:hypervisor reboot
Load averages: 1 minute   5 minute  15 minute
   0.12   0.20   0.21
Routing Engine status:
  Slot 1:
Current state  Backup
Temperature 38 degrees C / 100 degrees F
DRAM  11676 MB (12288 MB installed)
Memory utilization   7 percent
5 sec CPU utilization:
  User   0 percent
  Background 0 percent
  Kernel 0 percent
  Interrupt  0 percent
  Idle  99 percent
Model  RE-QFX10008
Serial ID  ACNV4655
Start time 2020-03-05 16:01:42 KST
Uptime 7 days, 21 hours, 3 minutes, 5 seconds
Last reboot reason 0x2000:hypervisor reboot
Load averages: 1 minute   5 minute  15 minute
   0.20   0.25   0.22

Class Item   Status Measurement
  Routing Engine 0 CPU   OK 34 degrees C / 93 degrees F
  Routing Engine 1 CPU   OK 38 degrees C / 100 degrees F
Temp  CB 0 Intake Temp SensorOK 26 degrees C / 78 degrees F
  CB 0 Exhaust Temp Sensor   OK 30 degrees C / 86 degrees F
  CB 1 Intake Temp SensorOK 26 degrees C / 78 degrees F
  CB 1 Exhaust Temp Sensor   OK 30 degrees C / 86 degrees F
  FPC 0 Intake-A Temp Sensor OK 37 degrees C / 98 degrees F
  FPC 0 Intake-B Temp Sensor OK 33 degrees C / 91 degrees F
  FPC 0 Mezz Intake-A Temp Sensor OK30 degrees C / 86 degrees F
  FPC 0 Mezz Intake-B Temp Sensor OK32 degrees C / 89 degrees F
  FPC 0 Mezz Intake-C Temp Sensor OK34 degrees C / 93 degrees F
  FPC 0 Exhaust-A Temp SensorOK 39 degrees C / 102 degrees F
  FPC 0 Exhaust-B Temp SensorOK 37 degrees C / 98 degrees F
  FPC 0 Exhaust-C Temp SensorOK 40 degrees C / 104 degrees F
  FPC 0 Exhaust-D Temp SensorOK 37 degrees C / 98 degrees F
  FPC 0 PE0 Temp Sensor  OK 52 degrees C / 125 degrees F
  FPC 0 PE1 Temp Sensor  OK 51 degrees C / 123 degrees F
  FPC 0 LCPU Temp Sensor OK 55 degrees C / 131 degrees F
Power Power Supply 0 OK 30 degrees C / 86 degrees F
  Power Supply 1 Check 
  Power Supply 2 OK 33 degrees C / 91 degrees F
  Power Supply 3 OK 34 degrees C / 93 degrees F
  Power Supply 4 Check 
  Power Supply 5 Check 
Fans  Fan Tray 0 Fan 0   OK Spinning at normal speed
  Fan Tray 0 Fan 1

Re: [ansible-project] rescue block does not print message despite being invoked

2020-03-12 Thread Shifa Shaikh
Missing parentheses where?

My code is very similar to a working sample here:

  fail:
msg: >-
  {{
command_result.stdout is search('775') |
ternary(
  "This REQ is already Deployed. ,
  "Database is not reachable."
)
  }}

On Fri, 13 Mar, 2020, 8:06 am James Cassell, 
wrote:

>
> On Thu, Mar 12, 2020, at 10:12 PM, Shifa Shaikh wrote:
> > Hi,
> >
> > I have a playbook with a task that greps for a string in a file. If the
> > string is found the block should fail which is the case. However, in
> > the fail module it fails to print the message.
> >
> > Here is my playbook:
> >
> > Here is my playbook:
> >
> > `
> > ---
> > - name: "Play 1"
> >  hosts: localhost
> >  tasks:
> > - block:
> > - name: "Search for IP"
> >  command: "grep -w {{ source_host }} {{ playbook_dir }}/allhost.hosts"
> > register: command_result
> >  failed_when: command_result.rc == 0 and action == "onboard"
> >
> >
> > rescue:
> > - name: Print custom conditional debug message
> >  fail:
> >  msg: >-
> > {{
> >  command_result.rc == 0 |
>
> You're missing parenthesis around the condition.
>
> V/r,
> James Cassell
>
> >  ternary(
> > "This IP is already On-Boarded.",
> > "The Database is not reachable."
> > )
> > }}
> >
> > `
> >
> >
> > Considering command_result.rc = 0; I was expecting "This IP is already
> > On-Boarded." to be printed however it does not. Can you please tell me
> > why.
> >
> > Output:
> >
> > `
> > TASK [Search for IP] *
> > [1;30mtask path: /tmp/filegaurd.yml:20[0m
> > [0;34mUsing module file
> > /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py[0m
> > [0;34mPipelining is enabled.[0m
> > [0;34m<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: user1[0m
> > [0;34m<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'[0m
> > [0;31mfatal: [localhost]: FAILED! => {[0m
> > [0;31m "changed": true, [0m
> > [0;31m "cmd": [[0m
> > [0;31m "grep", [0m
> > [0;31m "-w", [0m
> > [0;31m "10.9.9.91", [0m
> > [0;31m "/tmp/allhost.hosts"[0m
> > [0;31m ], [0m
> > [0;31m "delta": "0:00:00.096103", [0m
> > [0;31m "end": "2020-03-13 07:25:43.705938", [0m
> > [0;31m "failed_when_result": true, [0m
> > [0;31m "invocation": {[0m
> > [0;31m "module_args": {[0m
> > [0;31m "_raw_params": "grep -w 10.9.9.91 /tmp/allhost.hosts", [0m
> > [0;31m "_uses_shell": false, [0m
> > [0;31m "argv": null, [0m
> > [0;31m "chdir": null, [0m
> > [0;31m "creates": null, [0m
> > [0;31m "executable": null, [0m
> > [0;31m "removes": null, [0m
> > [0;31m "stdin": null, [0m
> > [0;31m "stdin_add_newline": true, [0m
> > [0;31m "strip_empty_ends": true, [0m
> > [0;31m "warn": true[0m
> > [0;31m }[0m
> > [0;31m }, [0m
> > [0;31m "rc": 0, [0m
> > [0;31m "start": "2020-03-13 07:25:43.609835", [0m
> > [0;31m "stderr": "", [0m
> > [0;31m "stderr_lines": [], [0m
> > [0;31m "stdout": "10.9.9.91 USERID=user1
> >
> files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar",
> [0m
> > [0;31m "stdout_lines": [[0m
> > [0;31m "10.9.9.91 USERID=user1
> >
> files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar"[0m
> > [0;31m ][0m
> > [0;31m}[0m
> >
> >
> > TASK [Print custom conditional debug message]
> **
> > [1;30mtask path: /tmp/filegaurd.yml:28[0m
> > [0;31mfatal: [localhost]: FAILED! => {[0m
> > [0;31m "changed": false, [0m
> > [0;31m "msg": "False "[0m
> > [0;31m}[0m
> >
> >
> > PLAY RECAP
> > *
> > [0;31mlocalhost[0m : [0;32mok=1 [0m changed=0 unreachable=0
> > [0;31mfailed=1 [0m skipped=0 [0;32mrescued=1 [0m ignored=0
> > `
> >
>
> --
> 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/53303de2-c158-4f30-b968-44d4b9be9d36%40www.fastmail.com
> .
>

-- 
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/CAJtox0mm%2B0ei8p5uLsts4O9Nw1kj%2BAgUPxYFUap_eAnsNcnCdA%40mail.gmail.com.


Re: [ansible-project] rescue block does not print message despite being invoked

2020-03-12 Thread James Cassell


On Thu, Mar 12, 2020, at 10:12 PM, Shifa Shaikh wrote:
> Hi, 
> 
> I have a playbook with a task that greps for a string in a file. If the 
> string is found the block should fail which is the case. However, in 
> the fail module it fails to print the message. 
> 
> Here is my playbook:
> 
> Here is my playbook:
> 
> `
> ---
> - name: "Play 1"
>  hosts: localhost
>  tasks:
> - block:
> - name: "Search for IP"
>  command: "grep -w {{ source_host }} {{ playbook_dir }}/allhost.hosts"
> register: command_result
>  failed_when: command_result.rc == 0 and action == "onboard"
> 
> 
> rescue:
> - name: Print custom conditional debug message
>  fail:
>  msg: >-
> {{
>  command_result.rc == 0 |

You're missing parenthesis around the condition.

V/r,
James Cassell

>  ternary(
> "This IP is already On-Boarded.",
> "The Database is not reachable."
> )
> }}
> 
> `
> 
> 
> Considering command_result.rc = 0; I was expecting "This IP is already 
> On-Boarded." to be printed however it does not. Can you please tell me 
> why.
> 
> Output:
> 
> `
> TASK [Search for IP] *
> [1;30mtask path: /tmp/filegaurd.yml:20[0m
> [0;34mUsing module file 
> /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py[0m
> [0;34mPipelining is enabled.[0m
> [0;34m<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: user1[0m
> [0;34m<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'[0m
> [0;31mfatal: [localhost]: FAILED! => {[0m
> [0;31m "changed": true, [0m
> [0;31m "cmd": [[0m
> [0;31m "grep", [0m
> [0;31m "-w", [0m
> [0;31m "10.9.9.91", [0m
> [0;31m "/tmp/allhost.hosts"[0m
> [0;31m ], [0m
> [0;31m "delta": "0:00:00.096103", [0m
> [0;31m "end": "2020-03-13 07:25:43.705938", [0m
> [0;31m "failed_when_result": true, [0m
> [0;31m "invocation": {[0m
> [0;31m "module_args": {[0m
> [0;31m "_raw_params": "grep -w 10.9.9.91 /tmp/allhost.hosts", [0m
> [0;31m "_uses_shell": false, [0m
> [0;31m "argv": null, [0m
> [0;31m "chdir": null, [0m
> [0;31m "creates": null, [0m
> [0;31m "executable": null, [0m
> [0;31m "removes": null, [0m
> [0;31m "stdin": null, [0m
> [0;31m "stdin_add_newline": true, [0m
> [0;31m "strip_empty_ends": true, [0m
> [0;31m "warn": true[0m
> [0;31m }[0m
> [0;31m }, [0m
> [0;31m "rc": 0, [0m
> [0;31m "start": "2020-03-13 07:25:43.609835", [0m
> [0;31m "stderr": "", [0m
> [0;31m "stderr_lines": [], [0m
> [0;31m "stdout": "10.9.9.91 USERID=user1 
> files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar",
>  [0m
> [0;31m "stdout_lines": [[0m
> [0;31m "10.9.9.91 USERID=user1 
> files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar"[0m
> [0;31m ][0m
> [0;31m}[0m
> 
> 
> TASK [Print custom conditional debug message] 
> **
> [1;30mtask path: /tmp/filegaurd.yml:28[0m
> [0;31mfatal: [localhost]: FAILED! => {[0m
> [0;31m "changed": false, [0m
> [0;31m "msg": "False "[0m
> [0;31m}[0m
> 
> 
> PLAY RECAP 
> *
> [0;31mlocalhost[0m : [0;32mok=1 [0m changed=0 unreachable=0 
> [0;31mfailed=1 [0m skipped=0 [0;32mrescued=1 [0m ignored=0 
> `
> 

-- 
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/53303de2-c158-4f30-b968-44d4b9be9d36%40www.fastmail.com.


[ansible-project] rescue block does not print message despite being invoked

2020-03-12 Thread Shifa Shaikh
Hi, 

I have a playbook with a task that greps for a string in a file. If the 
string is found the block should fail which is the case. However, in the 
fail module it fails to print the message. 

Here is my playbook:

Here is my playbook:

---
- name: "Play 1"
  hosts: localhost
  tasks:
   - block:
  - name: "Search for IP"
command: "grep -w {{ source_host }} {{ playbook_dir 
}}/allhost.hosts"
register: command_result
failed_when: command_result.rc == 0 and action == "onboard"


 rescue:
  - name: Print custom conditional debug message
fail:
  msg: >-
{{
  command_result.rc == 0 |
  ternary(
"This IP is already On-Boarded.",
"The Database is not reachable."
  )
}}



Considering command_result.rc = 0; I was expecting "This IP is already 
On-Boarded." to be printed however it does not. Can you please tell me why.

Output:

TASK [Search for IP] *
[1;30mtask path: /tmp/filegaurd.yml:20[0m
[0;34mUsing module file /usr/lib/python2.7/site-packages/ansible/modules/
commands/command.py[0m
[0;34mPipelining is enabled.[0m
[0;34m<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: user1[0m
[0;34m<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'[0m
[0;31mfatal: [localhost]: FAILED! => {[0m
[0;31m"changed": true, [0m
[0;31m"cmd": [[0m
[0;31m"grep", [0m
[0;31m"-w", [0m
[0;31m"10.9.9.91", [0m
[0;31m"/tmp/allhost.hosts"[0m
[0;31m], [0m
[0;31m"delta": "0:00:00.096103", [0m
[0;31m"end": "2020-03-13 07:25:43.705938", [0m
[0;31m"failed_when_result": true, [0m
[0;31m"invocation": {[0m
[0;31m"module_args": {[0m
[0;31m"_raw_params": "grep -w 10.9.9.91 /tmp/allhost.hosts", [0m
[0;31m"_uses_shell": false, [0m
[0;31m"argv": null, [0m
[0;31m"chdir": null, [0m
[0;31m"creates": null, [0m
[0;31m"executable": null, [0m
[0;31m"removes": null, [0m
[0;31m"stdin": null, [0m
[0;31m"stdin_add_newline": true, [0m
[0;31m"strip_empty_ends": true, [0m
[0;31m"warn": true[0m
[0;31m}[0m
[0;31m}, [0m
[0;31m"rc": 0, [0m
[0;31m"start": "2020-03-13 07:25:43.609835", [0m
[0;31m"stderr": "", [0m
[0;31m"stderr_lines": [], [0m
[0;31m"stdout": "10.9.9.91 USERID=user1 
files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar"
, [0m
[0;31m"stdout_lines": [[0m
[0;31m"10.9.9.91 USERID=user1 
files_list=/tmp/winstone4603745991442278706.jar,/tmp/winstone5835113081224811756.jar"
[0m
[0;31m][0m
[0;31m}[0m


TASK [Print custom conditional debug message] 
**
[1;30mtask path: /tmp/filegaurd.yml:28[0m
[0;31mfatal: [localhost]: FAILED! => {[0m
[0;31m"changed": false, [0m
[0;31m"msg": "False "[0m
[0;31m}[0m


PLAY RECAP 
*
[0;31mlocalhost[0m  : [0;32mok=1   [0m changed=0   
 unreachable=0[0;31mfailed=1   [0m skipped=0[0;32mrescued=1   [0m 
ignored=0   

-- 
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/7fe0646e-8f35-4d7f-be5b-10aa6e85a56c%40googlegroups.com.


Re: [ansible-project] Logging to readable format

2020-03-12 Thread RayO
I was able to resolve this finding the below thread. In my case I had to 
alter the config slightly to the below. This was to merge the text together 
no space and eliminate "_lines"

- name: print result
  debug:
var: output1.stdout_lines

- name: copy output to file
  copy: content="{{*output1.stdout|join("\n"*)}}" 
dest=/home/userfolder/ansible/cisco/logs/{{ inventory_hostname }}.txt


https://groups.google.com/forum/#!topic/ansible-project/4cJ7ho8uiAA

On Thursday, March 12, 2020 at 4:27:58 PM UTC-4, RayO wrote:
>
> Anyone have any thoughts on this?
>
> On Thursday, March 12, 2020 at 10:51:25 AM UTC-4, RayO wrote:
>>
>> Hi Stefan,
>>
>> Thanks for the reply. Unfortunately though it doesn't look like that 
>> worked. I replaced the below line with the entry you provided but it's 
>> still printing in a bad format
>>
>> copy: content="{{ output1.stdout_lines | join('\n') }}"
>>
>> Any other ideas?
>>
>> On Thursday, March 12, 2020 at 10:04:44 AM UTC-4, Stefan Hornburg (Racke) 
>> wrote:
>>>
>>> On 3/12/20 2:52 PM, RayO wrote: 
>>> > Hi. I have a very basic cisco IOS playbook i'm working on and when I 
>>> log the output to a file I cannot read the format. 
>>> > I read a few threads that mention enabling a callback option in the 
>>> ansible.cfg but that does not seem to work. Does 
>>> > anyone know how I can accomplish logging to a readable text? 
>>> > 
>>>
>>> Ansible stringifies the list object output1.stdout_lines, but you want 
>>> to print each element of this list to line 
>>> in the file. 
>>>
>>> Using  "{{ output1.stdout_lines | join('\n') }}" should do the trick. 
>>>
>>> Regards 
>>>   Racke 
>>>
>>> > --- 
>>> > 
>>> > - name: IOS General Checks 
>>> >   hosts: switches 
>>> >   gather_facts: false 
>>> >   connection: network_cli 
>>> > 
>>> >   tasks: 
>>> > - name: Standard IOS Checks 
>>> >   ios_command: 
>>> > commands: 
>>> >   - show int status 
>>> >   - show int description 
>>> >   register: output1 
>>> > 
>>> > - name: print result 
>>> >   debug: 
>>> > var: output1.stdout_lines 
>>> > 
>>> > - name: copy output to file 
>>> >   copy: content="{{ output1.stdout_lines }}" 
>>> dest=/home/user/ansible/cisco/logs/{{ inventory_hostname }}.txt 
>>> > 
>>> > ... 
>>> > 
>>> > # config file for ansible -- https://ansible.com/ 
>>> > # === 
>>> > 
>>> > # nearly all parameters can be overridden in ansible-playbook 
>>> > # or with command line flags. ansible will read ANSIBLE_CONFIG, 
>>> > # ansible.cfg in the current working directory, .ansible.cfg in 
>>> > # the home directory or /etc/ansible/ansible.cfg, whichever it 
>>> > # finds first 
>>> > 
>>> > [defaults] 
>>> > display_failed_stderr = no 
>>> > display_ok_hosts = yes 
>>> > display_skipped_hosts = yes 
>>> > show_custom_stats = no 
>>> > show_per_host_start = no 
>>> > 
>>> > -- 
>>> > 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...@googlegroups.com >> ansible-project+unsubscr...@googlegroups.com>. 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com
>>>  
>>> > <
>>> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com?utm_medium=email_source=footer>.
>>>  
>>>
>>>
>>>
>>> -- 
>>> Ecommerce and Linux consulting + Perl and web application programming. 
>>> Debian and Sympa administration. Provisioning with Ansible. 
>>>
>>>

-- 
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/e6558805-a401-44ec-97f9-09cd9f524b23%40googlegroups.com.


Re: [ansible-project] Logging to readable format

2020-03-12 Thread RayO
Anyone have any thoughts on this?

On Thursday, March 12, 2020 at 10:51:25 AM UTC-4, RayO wrote:
>
> Hi Stefan,
>
> Thanks for the reply. Unfortunately though it doesn't look like that 
> worked. I replaced the below line with the entry you provided but it's 
> still printing in a bad format
>
> copy: content="{{ output1.stdout_lines | join('\n') }}"
>
> Any other ideas?
>
> On Thursday, March 12, 2020 at 10:04:44 AM UTC-4, Stefan Hornburg (Racke) 
> wrote:
>>
>> On 3/12/20 2:52 PM, RayO wrote: 
>> > Hi. I have a very basic cisco IOS playbook i'm working on and when I 
>> log the output to a file I cannot read the format. 
>> > I read a few threads that mention enabling a callback option in the 
>> ansible.cfg but that does not seem to work. Does 
>> > anyone know how I can accomplish logging to a readable text? 
>> > 
>>
>> Ansible stringifies the list object output1.stdout_lines, but you want to 
>> print each element of this list to line 
>> in the file. 
>>
>> Using  "{{ output1.stdout_lines | join('\n') }}" should do the trick. 
>>
>> Regards 
>>   Racke 
>>
>> > --- 
>> > 
>> > - name: IOS General Checks 
>> >   hosts: switches 
>> >   gather_facts: false 
>> >   connection: network_cli 
>> > 
>> >   tasks: 
>> > - name: Standard IOS Checks 
>> >   ios_command: 
>> > commands: 
>> >   - show int status 
>> >   - show int description 
>> >   register: output1 
>> > 
>> > - name: print result 
>> >   debug: 
>> > var: output1.stdout_lines 
>> > 
>> > - name: copy output to file 
>> >   copy: content="{{ output1.stdout_lines }}" 
>> dest=/home/user/ansible/cisco/logs/{{ inventory_hostname }}.txt 
>> > 
>> > ... 
>> > 
>> > # config file for ansible -- https://ansible.com/ 
>> > # === 
>> > 
>> > # nearly all parameters can be overridden in ansible-playbook 
>> > # or with command line flags. ansible will read ANSIBLE_CONFIG, 
>> > # ansible.cfg in the current working directory, .ansible.cfg in 
>> > # the home directory or /etc/ansible/ansible.cfg, whichever it 
>> > # finds first 
>> > 
>> > [defaults] 
>> > display_failed_stderr = no 
>> > display_ok_hosts = yes 
>> > display_skipped_hosts = yes 
>> > show_custom_stats = no 
>> > show_per_host_start = no 
>> > 
>> > -- 
>> > 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...@googlegroups.com > ansible-project+unsubscr...@googlegroups.com>. 
>> > To view this discussion on the web visit 
>> > 
>> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com
>>  
>> > <
>> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com?utm_medium=email_source=footer>.
>>  
>>
>>
>>
>> -- 
>> Ecommerce and Linux consulting + Perl and web application programming. 
>> Debian and Sympa administration. Provisioning with Ansible. 
>>
>>

-- 
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/bcb3c7a4-6d7d-4ce5-9f77-b581ba6a66f4%40googlegroups.com.


Re: [ansible-project] Ansible password_hash issue

2020-03-12 Thread Dick Visser
The hardcoded admin hash uses the 2a version of bcrypt.
It may be that your application cannot handle the newer 2b variant of
bcrypt - which ansible creates.
But this sounds unlikely.

Can you try to create a password with ansible using a salt (so leaving
the "salt=None" out) ?

Dick

On Thu, 12 Mar 2020 at 15:52, Bala Mutyam  wrote:
>
> Hi,
>
> I've tried the rounds but no luck,still not able to login to UI.
>
> About the salt option, it's Sonarqube application which doesn't use salt.
>
> This is the command used on Sonarqube doc - 
> https://docs.sonarqube.org/latest/instance-administration/security/
>
> update users set crypted_password = 
> '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, 
> hash_method='BCRYPT' where login = 'admin'
>
>
> Thanks
>
>
> On Thursday, March 12, 2020 at 12:15:39 PM UTC, Dick Visser wrote:
>>
>> Hi
>>
>> Your hardcoded hash (the one "UI login only works") appears to use 10
>> rounds, while the hash generated by password_hash uses 12 (the
>> default).
>> Based on the docs at
>> https://passlib.readthedocs.io/en/stable/lib/passlib.hash.bcrypt.html#interface
>> you should be able to configure that as an argument for password_hash,
>> like:
>>
>> {{ admin_password | password_hash('bcrypt', salt=None, rounds=10) }}
>>
>> Not sure if this will fix your problem though, but worth trying.
>>
>> On a related note, you are deliberately not using a salt. That is
>> insecure, so if possible try to fix your workflow so that a salt is
>> used.
>> Your users will be thankful for it later.
>>
>>
>> Dick
>>
>>
>> On Thu, 12 Mar 2020 at 12:13, Bala Mutyam  wrote:
>> >
>> > Hi,
>> >
>> > I manged to run the task successfully but i'm not able to login with the 
>> > password to Sonarqube UI.
>> >
>> > ansible 2.7.7
>> >   config file = /etc/ansible/ansible.cfg
>> >   configured module search path = ['/root/.ansible/plugins/modules', 
>> > '/usr/share/ansible/plugins/modules']
>> >   ansible python module location = /usr/lib/python3/dist-packages/ansible
>> >   executable location = /usr/bin/ansible
>> >   python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
>> >
>> > - name: Reset Admin pw
>> >   become: yes
>> >   become_user: postgres
>> >   command: command: psql -c "update users set crypted_password = '{{ 
>> > admin_password | password_hash('bcrypt', salt=None) }}' where login = 
>> > 'admin'" sonarqube
>> >   tags: query
>> >
>> >
>> > I noticed the Ansible encrypted the password : 
>> > '$2b$12$QEsYuib1i6RO6fngZP4tzuUQvJMEo7k2jA48P.dVwwT5UE2fmygM.
>> >
>> > But it seems to be UI login only works with 
>> > $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO.
>> >
>> > Is it possible to force Anisble to encrypt the password as 
>> > $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO ?
>> >
>> >
>> >
>> >
>> > On Tuesday, March 10, 2020 at 6:32:03 PM UTC, Dan Linder wrote:
>> >>
>> >> What is the error and what is sending the error?  (i.e. is the error from 
>> >> "psql" or from Ansible itself?)
>> >>
>> >> Can you run the playbook with "-vvv" and paste in the errors the "Reset 
>> >> Admin pw" step produces.
>> >>
>> >> On Tuesday, March 10, 2020 at 11:12:17 AM UTC-5, Bala Mutyam wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> Thanks for the reply.  By hard coding the hash working fine.
>> >>>
>> >>> I'm trying to workout something like this but this is giving me an error.
>> >>>
>> >>>
>> >>> - name: Reset Admin pw
>> >>>   become: yes
>> >>>   become_user: postgres
>> >>>   command: psql -c "update users set crypted_password = '{{ 
>> >>> admin_password | password_hash('bcrypt', salt=None) }}' where login = 
>> >>> 'admin'" sonarqube
>> >>>   tags: query
>> >>>
>> >>>
>> >>>
>> >>> On Tuesday, March 10, 2020 at 2:13:28 PM UTC, Dick Visser wrote:
>> 
>>  You manual command has more arguments than the one in your task.
>>  Try making that consistent.
>> 
>>  If that doesn't work, try hardcoding the hash in your task to see if
>>  that works at all.
>> 
>> 
>> 
>> 
>>  On Tue, 10 Mar 2020 at 13:21, Bala Mutyam  wrote:
>>  >
>>  > Hi Everyone,
>>  >
>>  > I'm trying to create a task for below command but it's not working, 
>>  > can you help me how to make it work please?
>>  >
>>  > Command:
>>  >
>>  > update users set crypted_password = 
>>  > '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', 
>>  > salt=null, hash_method='BCRYPT' where login = 'admin'
>>  >
>>  > - name: Reset Admin pw
>>  >   become: yes
>>  >   become_user: postgres
>>  >   command: psql -c "update users set crypted_password = '{{ 
>>  > admin_password | password_hash('bcrypt') }}' where login = 'admin'" 
>>  > sonarqube
>>  >   tags: query
>>  >
>>  >
>>  > I'm successfully running the task but not able to login with the 
>>  > admin_password.
>>  >
>>  > --
>>  > You received this message because you are 

[ansible-project] Re: gcp_compute_* modules: trying to link using selfLink

2020-03-12 Thread Frank Gravato
Hi Lujaina,

Were you able to get this working I'm currently working on a project trying 
to get this working exactly in the same setup as your post.


On Thursday, January 2, 2020 at 9:46:16 AM UTC-5, Lujaina Abu Erban wrote:
>
> Thank you for the response, 
> But unfortunately, this also did not work for me
>
> On Thursday, January 2, 2020 at 2:41:50 PM UTC+1, JF wrote:
>>
>> Hello.
>> Try to use '- network: " {{ network }}"' instead of '- network: "{{ 
>> network.selfLink }}"'
>>
>> On Thursday, January 2, 2020 at 3:15:52 PM UTC+2, Lujaina Abu Erban wrote:
>>>
>>> I am new to using Ansible and the gcp_* modules.
>>>
>>> This is in relation to making use of Google Cloud Platform and Ansible. 
>>>
>>> Let us say that I have two projects: HOST_PROJECT and SERVICE_PROJECT. 
>>> They are both part of the same organisation.
>>> The host project, serves as a shared VPC host, while the service project 
>>> is using the shared VPC from the host project.
>>>
>>> Using Ansible, I want to create an instance template (using the 
>>> gcp_compute_instance_template module) to create a template the makes use of 
>>> the shared VPC network.
>>>
>>> Here is my ansible playbook:
>>>
>>> ---
>>> - name: test
>>>   hosts: localhost
>>>   gather_facts: no
>>>   vars_files:
>>> - ./vars/global.yaml
>>>   vars:
>>> service_account_file: 'gcloud-api-key.json'
>>> project: SERVICE_PROJECT
>>> auth_kind: serviceaccount
>>> scopes: 
>>>   - https://www.googleapis.com/auth/compute
>>>   
>>>
>>>   tasks: 
>>> - name: check network information
>>>   gcp_compute_network_info:
>>> filters:
>>>   - name = "{{ shared_network }}"
>>> project: HOST_PROJECT
>>> auth_kind: "{{ auth_kind }}"
>>> service_account_file: "{{ service_account_file }}"
>>>   register: network
>>> 
>>> - name: create an instance template
>>>   gcp_compute_instance_template:
>>> name: instance_template
>>> properties:
>>>   disks:
>>>   - auto_delete: 'true'
>>> boot: 'true'
>>> initialize_params:
>>>   source_image: projects/ubuntu-os-cloud/global/images/
>>> family/ubuntu-1604-lts
>>>   machine_type: f1-micro
>>>   network_interfaces:
>>>   - network: "{{ network.selfLink }}"
>>> access_configs:
>>> - name: access_config
>>>   type: ONE_TO_ONE_NAT
>>> project: SERVICE_PROJECT
>>> auth_kind: "{{ auth_kind }}"
>>> service_account_file: "{{ service_account_file }}"
>>> state: present
>>>   register: instancetemplate
>>>
>>> Running the following command: ansible-playbook test.yaml -vvv
>>> I get the following error:
>>>
>>> "msg": "argument network is of type  found in 'properties 
>>> -> network_interfaces'. and we were unable to convert to dict: dictionary 
>>> requested, could not parse JSON or key=value"
>>>
>>> I am sure it is referring to the network.selfLink line. 
>>>
>>> My question is, is this possible to do using this module? And am I 
>>> approaching this correctly?
>>>
>>> Thanks in advance!
>>>
>>

-- 
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/dc4cf61b-824a-4de2-9af8-741dd0533827%40googlegroups.com.


Re: [ansible-project] Ansible password_hash issue

2020-03-12 Thread Bala Mutyam
Hi,

I've tried the rounds but no luck,still not able to login to UI.

About the salt option, it's Sonarqube application which doesn't use salt.

This is the command used on Sonarqube doc - 
https://docs.sonarqube.org/latest/instance-administration/security/

update users set crypted_password = 
'$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, 
hash_method='BCRYPT' where login = 'admin'


Thanks


On Thursday, March 12, 2020 at 12:15:39 PM UTC, Dick Visser wrote:
>
> Hi 
>
> Your hardcoded hash (the one "UI login only works") appears to use 10 
> rounds, while the hash generated by password_hash uses 12 (the 
> default). 
> Based on the docs at 
>
> https://passlib.readthedocs.io/en/stable/lib/passlib.hash.bcrypt.html#interface
>  
> you should be able to configure that as an argument for password_hash, 
> like: 
>
> {{ admin_password | password_hash('bcrypt', salt=None, rounds=10) }} 
>
> Not sure if this will fix your problem though, but worth trying. 
>
> On a related note, you are deliberately not using a salt. That is 
> insecure, so if possible try to fix your workflow so that a salt is 
> used. 
> Your users will be thankful for it later. 
>
>
> Dick 
>
>
> On Thu, 12 Mar 2020 at 12:13, Bala Mutyam  > wrote: 
> > 
> > Hi, 
> > 
> > I manged to run the task successfully but i'm not able to login with the 
> password to Sonarqube UI. 
> > 
> > ansible 2.7.7 
> >   config file = /etc/ansible/ansible.cfg 
> >   configured module search path = ['/root/.ansible/plugins/modules', 
> '/usr/share/ansible/plugins/modules'] 
> >   ansible python module location = 
> /usr/lib/python3/dist-packages/ansible 
> >   executable location = /usr/bin/ansible 
> >   python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0] 
> > 
> > - name: Reset Admin pw 
> >   become: yes 
> >   become_user: postgres 
> >   command: command: psql -c "update users set crypted_password = '{{ 
> admin_password | password_hash('bcrypt', salt=None) }}' where login = 
> 'admin'" sonarqube 
> >   tags: query 
> > 
> > 
> > I noticed the Ansible encrypted the password : 
> '$2b$12$QEsYuib1i6RO6fngZP4tzuUQvJMEo7k2jA48P.dVwwT5UE2fmygM. 
> > 
> > But it seems to be UI login only works with 
> $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO. 
> > 
> > Is it possible to force Anisble to encrypt the password as 
> $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO ? 
> > 
> > 
> > 
> > 
> > On Tuesday, March 10, 2020 at 6:32:03 PM UTC, Dan Linder wrote: 
> >> 
> >> What is the error and what is sending the error?  (i.e. is the error 
> from "psql" or from Ansible itself?) 
> >> 
> >> Can you run the playbook with "-vvv" and paste in the errors the "Reset 
> Admin pw" step produces. 
> >> 
> >> On Tuesday, March 10, 2020 at 11:12:17 AM UTC-5, Bala Mutyam wrote: 
> >>> 
> >>> Hi, 
> >>> 
> >>> Thanks for the reply.  By hard coding the hash working fine. 
> >>> 
> >>> I'm trying to workout something like this but this is giving me an 
> error. 
> >>> 
> >>> 
> >>> - name: Reset Admin pw 
> >>>   become: yes 
> >>>   become_user: postgres 
> >>>   command: psql -c "update users set crypted_password = '{{ 
> admin_password | password_hash('bcrypt', salt=None) }}' where login = 
> 'admin'" sonarqube 
> >>>   tags: query 
> >>> 
> >>> 
> >>> 
> >>> On Tuesday, March 10, 2020 at 2:13:28 PM UTC, Dick Visser wrote: 
>  
>  You manual command has more arguments than the one in your task. 
>  Try making that consistent. 
>  
>  If that doesn't work, try hardcoding the hash in your task to see if 
>  that works at all. 
>  
>  
>  
>  
>  On Tue, 10 Mar 2020 at 13:21, Bala Mutyam  
> wrote: 
>  > 
>  > Hi Everyone, 
>  > 
>  > I'm trying to create a task for below command but it's not working, 
> can you help me how to make it work please? 
>  > 
>  > Command: 
>  > 
>  > update users set crypted_password = 
> '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, 
> hash_method='BCRYPT' where login = 'admin' 
>  > 
>  > - name: Reset Admin pw 
>  >   become: yes 
>  >   become_user: postgres 
>  >   command: psql -c "update users set crypted_password = '{{ 
> admin_password | password_hash('bcrypt') }}' where login = 'admin'" 
> sonarqube 
>  >   tags: query 
>  > 
>  > 
>  > I'm successfully running the task but not able to login with the 
> admin_password. 
>  > 
>  > -- 
>  > 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...@googlegroups.com. 
>  > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/1d3e8db8-01b9-4363-a3aa-67e077f35b62%40googlegroups.com.
>  
>
>  
>  
>  
>  -- 
>  Dick Visser 
>  Trust & Identity Service 

Re: [ansible-project] Logging to readable format

2020-03-12 Thread RayO
Hi Stefan,

Thanks for the reply. Unfortunately though it doesn't look like that 
worked. I replaced the below line with the entry you provided but it's 
still printing in a bad format

copy: content="{{ output1.stdout_lines | join('\n') }}"

Any other ideas?

On Thursday, March 12, 2020 at 10:04:44 AM UTC-4, Stefan Hornburg (Racke) 
wrote:
>
> On 3/12/20 2:52 PM, RayO wrote: 
> > Hi. I have a very basic cisco IOS playbook i'm working on and when I log 
> the output to a file I cannot read the format. 
> > I read a few threads that mention enabling a callback option in the 
> ansible.cfg but that does not seem to work. Does 
> > anyone know how I can accomplish logging to a readable text? 
> > 
>
> Ansible stringifies the list object output1.stdout_lines, but you want to 
> print each element of this list to line 
> in the file. 
>
> Using  "{{ output1.stdout_lines | join('\n') }}" should do the trick. 
>
> Regards 
>   Racke 
>
> > --- 
> > 
> > - name: IOS General Checks 
> >   hosts: switches 
> >   gather_facts: false 
> >   connection: network_cli 
> > 
> >   tasks: 
> > - name: Standard IOS Checks 
> >   ios_command: 
> > commands: 
> >   - show int status 
> >   - show int description 
> >   register: output1 
> > 
> > - name: print result 
> >   debug: 
> > var: output1.stdout_lines 
> > 
> > - name: copy output to file 
> >   copy: content="{{ output1.stdout_lines }}" 
> dest=/home/user/ansible/cisco/logs/{{ inventory_hostname }}.txt 
> > 
> > ... 
> > 
> > # config file for ansible -- https://ansible.com/ 
> > # === 
> > 
> > # nearly all parameters can be overridden in ansible-playbook 
> > # or with command line flags. ansible will read ANSIBLE_CONFIG, 
> > # ansible.cfg in the current working directory, .ansible.cfg in 
> > # the home directory or /etc/ansible/ansible.cfg, whichever it 
> > # finds first 
> > 
> > [defaults] 
> > display_failed_stderr = no 
> > display_ok_hosts = yes 
> > display_skipped_hosts = yes 
> > show_custom_stats = no 
> > show_per_host_start = no 
> > 
> > -- 
> > 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...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
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/4aefae5e-40bc-4ceb-84e3-b7286a60e344%40googlegroups.com.


Re: [ansible-project] Logging to readable format

2020-03-12 Thread Stefan Hornburg (Racke)
On 3/12/20 2:52 PM, RayO wrote:
> Hi. I have a very basic cisco IOS playbook i'm working on and when I log the 
> output to a file I cannot read the format.
> I read a few threads that mention enabling a callback option in the 
> ansible.cfg but that does not seem to work. Does
> anyone know how I can accomplish logging to a readable text?
> 

Ansible stringifies the list object output1.stdout_lines, but you want to print 
each element of this list to line
in the file.

Using  "{{ output1.stdout_lines | join('\n') }}" should do the trick.

Regards
  Racke

> ---
> 
> - name: IOS General Checks
>   hosts: switches
>   gather_facts: false
>   connection: network_cli
> 
>   tasks:
>     - name: Standard IOS Checks
>       ios_command:
>         commands:
>           - show int status
>           - show int description
>       register: output1
> 
>     - name: print result
>       debug:
>         var: output1.stdout_lines
> 
>     - name: copy output to file
>       copy: content="{{ output1.stdout_lines }}" 
> dest=/home/sideswipe/ansible/cisco/logs/{{ inventory_hostname }}.txt
> 
> ...
> 
> # config file for ansible -- https://ansible.com/
> # ===
> 
> # nearly all parameters can be overridden in ansible-playbook
> # or with command line flags. ansible will read ANSIBLE_CONFIG,
> # ansible.cfg in the current working directory, .ansible.cfg in
> # the home directory or /etc/ansible/ansible.cfg, whichever it
> # finds first
> 
> [defaults]
> display_failed_stderr = no
> display_ok_hosts = yes
> display_skipped_hosts = yes
> show_custom_stats = no
> show_per_host_start = no
> 
> -- 
> 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/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com
> .


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

-- 
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/30f2b3ab-2e0b-9bc7-5588-cce911dbb0b3%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Logging to readable format

2020-03-12 Thread RayO
Hi. I have a very basic cisco IOS playbook i'm working on and when I log 
the output to a file I cannot read the format. I read a few threads that 
mention enabling a callback option in the ansible.cfg but that does not 
seem to work. Does anyone know how I can accomplish logging to a readable 
text?

---

- name: IOS General Checks
  hosts: switches
  gather_facts: false
  connection: network_cli

  tasks:
- name: Standard IOS Checks
  ios_command:
commands:
  - show int status
  - show int description
  register: output1

- name: print result
  debug:
var: output1.stdout_lines

- name: copy output to file
  copy: content="{{ output1.stdout_lines }}" 
dest=/home/sideswipe/ansible/cisco/logs/{{ inventory_hostname }}.txt

...

# config file for ansible -- https://ansible.com/
# ===

# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]
display_failed_stderr = no
display_ok_hosts = yes
display_skipped_hosts = yes
show_custom_stats = no
show_per_host_start = no

-- 
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/098fbdd3-21e1-4a4c-afa2-16b1649ce4f7%40googlegroups.com.


Re: [ansible-project] Ansible password_hash issue

2020-03-12 Thread Dick Visser
Hi

Your hardcoded hash (the one "UI login only works") appears to use 10
rounds, while the hash generated by password_hash uses 12 (the
default).
Based on the docs at
https://passlib.readthedocs.io/en/stable/lib/passlib.hash.bcrypt.html#interface
you should be able to configure that as an argument for password_hash,
like:

{{ admin_password | password_hash('bcrypt', salt=None, rounds=10) }}

Not sure if this will fix your problem though, but worth trying.

On a related note, you are deliberately not using a salt. That is
insecure, so if possible try to fix your workflow so that a salt is
used.
Your users will be thankful for it later.


Dick


On Thu, 12 Mar 2020 at 12:13, Bala Mutyam  wrote:
>
> Hi,
>
> I manged to run the task successfully but i'm not able to login with the 
> password to Sonarqube UI.
>
> ansible 2.7.7
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = ['/root/.ansible/plugins/modules', 
> '/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python3/dist-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
>
> - name: Reset Admin pw
>   become: yes
>   become_user: postgres
>   command: command: psql -c "update users set crypted_password = '{{ 
> admin_password | password_hash('bcrypt', salt=None) }}' where login = 
> 'admin'" sonarqube
>   tags: query
>
>
> I noticed the Ansible encrypted the password : 
> '$2b$12$QEsYuib1i6RO6fngZP4tzuUQvJMEo7k2jA48P.dVwwT5UE2fmygM.
>
> But it seems to be UI login only works with 
> $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO.
>
> Is it possible to force Anisble to encrypt the password as 
> $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO ?
>
>
>
>
> On Tuesday, March 10, 2020 at 6:32:03 PM UTC, Dan Linder wrote:
>>
>> What is the error and what is sending the error?  (i.e. is the error from 
>> "psql" or from Ansible itself?)
>>
>> Can you run the playbook with "-vvv" and paste in the errors the "Reset 
>> Admin pw" step produces.
>>
>> On Tuesday, March 10, 2020 at 11:12:17 AM UTC-5, Bala Mutyam wrote:
>>>
>>> Hi,
>>>
>>> Thanks for the reply.  By hard coding the hash working fine.
>>>
>>> I'm trying to workout something like this but this is giving me an error.
>>>
>>>
>>> - name: Reset Admin pw
>>>   become: yes
>>>   become_user: postgres
>>>   command: psql -c "update users set crypted_password = '{{ admin_password 
>>> | password_hash('bcrypt', salt=None) }}' where login = 'admin'" sonarqube
>>>   tags: query
>>>
>>>
>>>
>>> On Tuesday, March 10, 2020 at 2:13:28 PM UTC, Dick Visser wrote:

 You manual command has more arguments than the one in your task.
 Try making that consistent.

 If that doesn't work, try hardcoding the hash in your task to see if
 that works at all.




 On Tue, 10 Mar 2020 at 13:21, Bala Mutyam  wrote:
 >
 > Hi Everyone,
 >
 > I'm trying to create a task for below command but it's not working, can 
 > you help me how to make it work please?
 >
 > Command:
 >
 > update users set crypted_password = 
 > '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', 
 > salt=null, hash_method='BCRYPT' where login = 'admin'
 >
 > - name: Reset Admin pw
 >   become: yes
 >   become_user: postgres
 >   command: psql -c "update users set crypted_password = '{{ 
 > admin_password | password_hash('bcrypt') }}' where login = 'admin'" 
 > sonarqube
 >   tags: query
 >
 >
 > I'm successfully running the task but not able to login with the 
 > admin_password.
 >
 > --
 > 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...@googlegroups.com.
 > To view this discussion on the web visit 
 > https://groups.google.com/d/msgid/ansible-project/1d3e8db8-01b9-4363-a3aa-67e077f35b62%40googlegroups.com.



 --
 Dick Visser
 Trust & Identity Service Operations Manager
 GÉANT
>
> --
> 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/e63eb9ef-eee9-4739-9f6c-3691b4aee318%40googlegroups.com.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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 

Re: [ansible-project] no hosts matched

2020-03-12 Thread Dick Visser
hi

it's pretty obvious from the error, with exact file and line number etc:

On Thu, 12 Mar 2020 at 11:15,  wrote:
> [WARNING]:  * Failed to parse /etc/ansible/hosts with yaml plugin: Syntax 
> Error
>
> while loading YAML.   did not find expected   The error 
> appears
>
> to be in '/etc/ansible/hosts': line 48, column 1, but may be elsewhere in the
>
> file depending on the exact syntax problem.  The offending line appears to be:
>
> [test] 192.168.1.120 ^ here
>
>   File "/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 
> 280, in parse_source
>
> plugin.parse(self._inventory, self._loader, source, cache=cache)
>
>   File "/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/yaml.py", 
> line 105, in parse
>
> raise AnsibleParserError(e)


But there is another problem as well:

> [WARNING]:  * Failed to parse /etc/ansible/hosts with ini plugin:
>
> /etc/ansible/hosts:69: Expected key=value host variable assignment, got:
>
> ansible


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwNBK9DVuYhCQRSm49foRJK_z24xvm-k5pY%3DjPkQfgJP7g%40mail.gmail.com.


Re: [ansible-project] Ansible password_hash issue

2020-03-12 Thread Bala Mutyam
Hi,

I manged to run the task successfully but i'm not able to login with the 
password to Sonarqube UI.

ansible 2.7.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

- name: Reset Admin pw
  become: yes
  become_user: postgres
  command: command: psql -c "update users set crypted_password = '{{ 
admin_password | password_hash('bcrypt', salt=None) }}' where login = 'admin'" 
sonarqube
  tags: query


I noticed the Ansible encrypted the password 
: '$2b$12$QEsYuib1i6RO6fngZP4tzuUQvJMEo7k2jA48P.dVwwT5UE2fmygM.

But it seems to be UI login only works 
with $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO.

Is it possible to force Anisble to encrypt the password 
as $2a$10$ggLrB/SKx901ctz13V1OIOu2UJzApbdfFCR5KJ6X6GbH9VNAzqglO ?




On Tuesday, March 10, 2020 at 6:32:03 PM UTC, Dan Linder wrote:
>
> What is the error and what is sending the error?  (i.e. is the error from 
> "psql" or from Ansible itself?)
>
> Can you run the playbook with "-vvv" and paste in the errors the "Reset 
> Admin pw" step produces.
>
> On Tuesday, March 10, 2020 at 11:12:17 AM UTC-5, Bala Mutyam wrote:
>>
>> Hi,
>>
>> Thanks for the reply.  By hard coding the hash working fine. 
>>
>> I'm trying to workout something like this but this is giving me an error.
>>
>>
>> - name: Reset Admin pw
>>   become: yes
>>   become_user: postgres
>>   command: psql -c "update users set crypted_password = '{{ admin_password | 
>> password_hash('bcrypt', salt=None) }}' where login = 'admin'" sonarqube
>>   tags: query
>>
>>
>>
>> On Tuesday, March 10, 2020 at 2:13:28 PM UTC, Dick Visser wrote:
>>>
>>> You manual command has more arguments than the one in your task. 
>>> Try making that consistent. 
>>>
>>> If that doesn't work, try hardcoding the hash in your task to see if 
>>> that works at all. 
>>>
>>>
>>>
>>>
>>> On Tue, 10 Mar 2020 at 13:21, Bala Mutyam  wrote: 
>>> > 
>>> > Hi Everyone, 
>>> > 
>>> > I'm trying to create a task for below command but it's not working, 
>>> can you help me how to make it work please? 
>>> > 
>>> > Command: 
>>> > 
>>> > update users set crypted_password = 
>>> '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', salt=null, 
>>> hash_method='BCRYPT' where login = 'admin' 
>>> > 
>>> > - name: Reset Admin pw 
>>> >   become: yes 
>>> >   become_user: postgres 
>>> >   command: psql -c "update users set crypted_password = '{{ 
>>> admin_password | password_hash('bcrypt') }}' where login = 'admin'" 
>>> sonarqube 
>>> >   tags: query 
>>> > 
>>> > 
>>> > I'm successfully running the task but not able to login with the 
>>> admin_password. 
>>> > 
>>> > -- 
>>> > 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...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/1d3e8db8-01b9-4363-a3aa-67e077f35b62%40googlegroups.com.
>>>  
>>>
>>>
>>>
>>>
>>> -- 
>>> Dick Visser 
>>> Trust & Identity Service Operations Manager 
>>> GÉANT 
>>>
>>

-- 
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/e63eb9ef-eee9-4739-9f6c-3691b4aee318%40googlegroups.com.


RE: [ansible-project] no hosts matched

2020-03-12 Thread sandy.hung
I change hosts, but still error connect.

 �

[test]

192.168.1.120

 �

[vars]

ansible_user=sandy

ansible_sudo_pass=''

 �

ansible 2.9.6

  config file = /etc/ansible/ansible.cfg

  configured module search path = [u'/home/sandy/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']

  ansible python module location = /usr/lib/python2.7/dist-packages/ansible

  executable location = /usr/bin/ansible

  python version = 2.7.17 (default, Nov  7 2019, 10:07:09) [GCC 7.4.0]

Using /etc/ansible/ansible.cfg as config file

host_list declined parsing /etc/ansible/hosts as it did not pass its 
verify_file() method

[WARNING]:  * Failed to parse /etc/ansible/hosts with script plugin: problem

running /etc/ansible/hosts --list ([Errno 8] Exec format error)

  File "/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 
280, in parse_source

plugin.parse(self._inventory, self._loader, source, cache=cache)

  File "/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/script.py", 
line 161, in parse

raise AnsibleParserError(to_native(e))

[WARNING]:  * Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error

while loading YAML.   did not find expected   The error appears

to be in '/etc/ansible/hosts': line 48, column 1, but may be elsewhere in the

file depending on the exact syntax problem.  The offending line appears to be:

[test] 192.168.1.120 ^ here

  File "/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 
280, in parse_source

plugin.parse(self._inventory, self._loader, source, cache=cache)

  File "/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/yaml.py", 
line 105, in parse

raise AnsibleParserError(e)

[WARNING]:  * Failed to parse /etc/ansible/hosts with ini plugin:

/etc/ansible/hosts:69: Expected key=value host variable assignment, got:

ansible

  File "/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 
280, in parse_source

plugin.parse(self._inventory, self._loader, source, cache=cache)

  File "/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/ini.py", 
line 138, in parse

raise AnsibleParserError(e)

[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that

the implicit localhost does not match 'all'

 �

BR

Sandy

 �

From: ansible-project@googlegroups.com  On 
Behalf Of Mark Whaite
Sent: Wednesday, March 11, 2020 6:40 PM
To: ansible-project@googlegroups.com
Subject: Re: [ansible-project] no hosts matched

  

Hi Sandy

  

I think it is the 'my hosts' line. I would place that   between []. or remove 
it. I would   also move the vars to a group ver. So something  like this.

  

[my_hosts]
192.168.1.120

[my_hosts:vars]
ansible_connection=local
ansible_sudo_pass='xxx'
ansible_connection=local

  

On Wed, 11 Mar 2020 at 10:15, Sandy Hung mailto:sandy.h...@abagile.com> > wrote:

Dear all:

  

  I have been normal before but this error message appeared in a few week

can you help me.  

thanks.

  

  

sandy@test-VirtualBox:~$ sudo ansible-playbook nfsclient.yml -i myinventory

[WARNING]: Unable to parse /home/sandy/myinventory as an inventory source

  

[WARNING]: No inventory was parsed, only implicit localhost is available

  

[WARNING]: provided hosts list is empty, only localhost is available. Note that

the implicit localhost does not match 'all'

  

  

PLAY [all] *

skipping: no hosts matched

  

  

my hosts

192.168.1.120 ansible_user=sandy

192.168.1.120 ansible_sudo_pass='xxx'

192.168.1.120 ansible_connection=local

  

-- 
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/7912138a-9412-4cc5-9fb1-96d046112925%40googlegroups.com
 

 .




  

-- 

Mark Whaite, Systems Administrator 
Adelard LLP 
Adelard LLP, Units 24 Waterside, 44-48 Wharf Road, London N1 7UX 
Tel: 020 7832 5850 
Web: http://www.adelard.com 

This e-mail, and any attachments, is confidential and for the use of the 
addressee only. If you are not the intended recipient, please telephone 020 
7832 5850. We do not accept legal responsibility for this e-mail or any 
viruses. 

Registered office: Stourside Place, Station Road, Ashford, Kent TN12 1PP 
Registered in England & Wales no. OC 304551. VAT no. 454 489808

-- 
You received this message because you are subscribed to the Google 

Re: [ansible-project] Inventory gathering including docker version

2020-03-12 Thread Kuber User
Thank you, Felix, will explore.

On Wed, Mar 11, 2020 at 6:03 AM 'Felix Fontein' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi,
>
> you should be able to use the docker_host_info module to find out the
> dcker daemon version. Check out its host_info return value
> (
> https://docs.ansible.com/ansible/latest/modules/docker_host_info_module.html#return-host_info
> ).
>
> How you can integrate that into your output, that's another story...
>
> Cheers,
> Felix
>
>
>
> On Tue, 10 Mar 2020 19:13:27 -0700 (PDT)
> Kuber User  wrote:
>
> > HI,
> > I am doing a similar script to gather inventory of remote systems.
> > I have the input list in my inventory file as the list of remote IPs.
> > I need to extract the fields like CPU, RAM, Kernel version, and the
> > docker version running on those boxes.
> > I am currently using the following cmd to extract what I need, only
> > to html format
> >
> > 1. ansible -i my_inv_file -m setup --tree out/ all
> > 2. ansible-cmdb
> >
> --exclude-cols=dtap,comment,ext_id,fqdn,all_ipv4,all_ipv6,os,arch,virt,mem_usage,swap_usage,disk_usage,physdisk_size,nr_of_ifaces,prodname,prodserial
>
> > -t html_fancy_split -p local_js=1 out/
> > This is getting me the cols I need. I also need sensible version.
> >
> > To this end, I tried to add an additional option "-C
> > examples/cust-cols.conf" to the above command. And was able to get
> > some dummy columns added to test, but I need to have docker_version
> > field. Can you please help me.
> >
>
> --
> 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/2020030337.448c8c00%40rovaniemi
> .
>

-- 
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/CALAydfCGs9KozJ9LeOfPRgVFBn8KhcJs08yhun1jEt9gMSokvg%40mail.gmail.com.


Re: [ansible-project] ansible privilege escalation ( sudo su - )

2020-03-12 Thread Dick Visser
You manually use sudo but the in your playbook you use su?

Please read again carefully
https://docs.ansible.com/ansible/latest/user_guide/become.html



On Thu, 12 Mar 2020 at 06:02, Suresh R  wrote:

> i have command sudo su - is working fine when we do ssh to the server.
> BTW we were unable to execute the same through ansible.
>
> Here is my ansible playbook and ansible.cfg
>
> -
>   name: play1
>   hosts: all
>   become: yes
>   become_user: root
>   become_method: su
>
>   tasks:
>  - name: task1
>command: whoami
>
>
> ansible.cfg
>
> [defaults]
> timeout = 30
> host_key_checking = False
> log_path=/automation/logs/ansible.log
> forks = 20
> [privilege_escalation]
> become_exe='sudo su -'
>
> upon execution getting the below error.  Not sure what am missing, can you
> help me to narrow down the issue.
>
> debug1: auto-mux: Trying existing master
> debug2: fd 3 setting O_NONBLOCK
> debug2: mux_client_hello_exchange: master version 4
> debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
> debug3: mux_client_request_session: entering
> debug3: mux_client_request_alive: entering
> debug3: mux_client_request_alive: done pid = 22143
> debug3: mux_client_request_session: session request sent
> debug1: mux_client_request_session: master session id: 2
> debug3: mux_client_read_packet: read header failed: Broken pipe
> debug2: Received exit status from master 1
> Shared connection to hostname closed.
>   module_stdout: |-
> Sorry, user username is not allowed to execute '/bin/su - root -c
> /bin/sh -c 'echo BECOME-SUCCESS-dfpfswsrshaqshzzihkprpuufxkkidfh;
> /usr/bin/python
> /local_home/username/.ansible/tmp/ansible-tmp-1583988062.13-162077793143077/setup.py''
> as root on hostname.
>   msg: MODULE FAILURE
>   rc: 1
>
>
>
>
> --
> 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/bf0a6b05-1fd9-4bda-98e2-5e8f6f3717d8%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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/CAL8fbwNTi5UdJvvWDTQNyyvqvuspVgzrb1cQscZjw5Wws326Nw%40mail.gmail.com.