Re: [ansible-project] Ansible ping report

2023-11-08 Thread Thanh Nguyen Duc
You may try the attached playbook i am using for linux, windows will be
similar as well. The report will be in html format

Vào Th 4, 8 thg 11, 2023 vào lúc 22:22 Dimitri Yioulos <
dimitri.g.yiou...@gmail.com> đã viết:

> Vladimir, this is very good, and very appreciated. Your playbook looks for
> hosts that are pingable, and marks them as not unreachable.  But, my goal
> is to see if hosts are Ansible-pingable (not ICMP-pingable; I believe
> there's a difference) or not, then take *all* of the output, and create a
> report from it. Thus, i end up with a report of hosts that are either
> Ansible-pingable or not.
>
> On Tuesday, November 7, 2023 at 2:15:30 PM UTC-5 Vladimir Botka wrote:
>
>> Sure, here is the gist
>> https://gist.github.com/vbotka/10c57962976dd1e2dd3e9411d3745c75
>>
>> (Is it possible to reasonably format a code in Google Groups?)
>> On Tuesday, November 7, 2023 at 6:55:50 PM UTC+1 dbs34 wrote:
>>
>>> would you mind sharing the whole, newly updated playbook?  thank you!
>>>
>>> On Monday, November 6, 2023 at 2:58:31 PM UTC-5 Vladimir Botka wrote:
>>>
 On Fri, 3 Nov 2023 08:40:19 -0700 (PDT)
 Dimitri Yioulos  wrote:

 > --- PING REPORT ---
 > {% for pr in ping_result.results %}
 > {{ pr.stdout_lines | first }}
 > {{ pr.stdout_lines | last }}
 >
 > {% endfor %}
 > run_once: true
 > delegate_to: localhost
 >
 > That works fine. However, I want to use ansible.builtin.ping ...


 Ignore unreachable hosts in a block

 - block:
 - ping:
 register: out
 - set_fact:
 unr: "{{ out.unreachable|d(false) }}"
 ignore_unreachable: true

 and declare the dictionary

 h_unr: "{{ dict(ansible_play_hosts_all|
 zip(ansible_play_hosts_all|
 map('extract', hostvars, 'unr'))) }}"

 For example, the below play

 - hosts: test_01,test_05,test_06,test_07
 gather_facts: false

 vars:

 h_unr: "{{ dict(ansible_play_hosts_all|
 zip(ansible_play_hosts_all|
 map('extract', hostvars, 'unr'))) }}"

 tasks:

 - block:
 - ping:
 register: out
 - set_fact:
 unr: "{{ out.unreachable|d(false) }}"
 ignore_unreachable: true

 - debug:
 var: h_unr
 run_once: true
 delegate_to: localhost

 gives (abridged)

 ok: [test_01 -> localhost] =>
 h_unr:
 test_01: false
 test_05: true
 test_06: true
 test_07: true

 --
 Vladimir Botka

>>> --
> 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/47bbdd8e-7b5f-4dfc-ac60-375a532a9adbn%40googlegroups.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/CA%2BnV637NJgVD2dmR15fdUHf6eGfdM%2B-AZxao_S6fPEeu-%3D0mxA%40mail.gmail.com.


exportreport.yml
Description: Binary data


linux_ping.j2
Description: Binary data


general.yml
Description: Binary data


createreport.yml
Description: Binary data


Daily_LinuxPing.yml
Description: Binary data


Re: [ansible-project] Running update grub-pc in noninteractive mode

2023-10-23 Thread Thanh Nguyen Duc
Example if you know your command only need to execute from the first disk

fdisk -l | grep "^/dev/" | cut -d' ' -f1

You may need to custom abit then.

Vào Th 2, 23 thg 10, 2023 vào lúc 18:45 Kathy Lyons 
đã viết:

> The only issue is that I don't know what the name of the disk is -
> /dev/sda, dev/nvme0n1p1, etc.
>
> On Mon, Oct 23, 2023 at 6:36 AM Thanh Nguyen Duc <
> ng.ducthanh1...@gmail.com> wrote:
>
>> You may try to gather fact, register the fact then execute the command in
>> the next task. For me i usually  use shell to query what i need before
>> proceeding next step, save a bit of time.
>>
>> --- Example:
>> ---
>> - name: Set location
>>   hosts: localhost
>>   connection: local
>>   gather_facts: false
>>   tasks:
>>   - name: Output disk information
>> shell: fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1
>> register: myoutput
>>   - name: install
>> shell: echo "{{myoutput.stdout_lines}}"
>>
>>
>>
>>
>>
>> Vào Th 2, 23 thg 10, 2023 vào lúc 18:14 Kathy L 
>> đã viết:
>>
>>> We are trying to update packages on several AWS servers via ansible. In
>>> the beginning of our playbook we have the environment to noninteractive
>>> like this:
>>> environment:
>>>DEBIAN_FRONTEND: noninteractive
>>>
>>> When I run an update (or try to install anything, I get the error
>>> stating "/dev/sda does not exist". That is because for example, when
>>> provisioning AWS nodes, the disk type is not /dev/sda but something else.
>>>
>>> My question is how do i run update grub-pc with a specific disk?  I'm
>>> assuming I would get the disk "name" from ansible_facts (devices), grab the
>>> first disk, then run something similar to  "apt install grub-pc /dev/nvme01"
>>>
>>> Is there a way to do this?  I tried the line above and it failed and I'm
>>> out of ideas.
>>>
>>> --
>>> 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/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/7EUtcfIe23E/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CA%2BnV635dwsmrtjGWE0bwSDmaq4_0a0A3GXS1oM2XikYJ03823A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnV635dwsmrtjGWE0bwSDmaq4_0a0A3GXS1oM2XikYJ03823A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAK9%2BsMc__0%2B0%2BidM3eS6aHaDRohsNuhoiF3kyR8qAu_mg2pi_g%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMc__0%2B0%2BidM3eS6aHaDRohsNuhoiF3kyR8qAu_mg2pi_g%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CA%2BnV634yGZUm-ZxRDgfbvy5%3Df2-0UMH0%3DF5NdaVgdDRgYCgOtQ%40mail.gmail.com.


Re: [ansible-project] Running update grub-pc in noninteractive mode

2023-10-23 Thread Thanh Nguyen Duc
You may try to gather fact, register the fact then execute the command in
the next task. For me i usually  use shell to query what i need before
proceeding next step, save a bit of time.

--- Example:
---
- name: Set location
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: Output disk information
shell: fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1
register: myoutput
  - name: install
shell: echo "{{myoutput.stdout_lines}}"





Vào Th 2, 23 thg 10, 2023 vào lúc 18:14 Kathy L  đã
viết:

> We are trying to update packages on several AWS servers via ansible. In
> the beginning of our playbook we have the environment to noninteractive
> like this:
> environment:
>DEBIAN_FRONTEND: noninteractive
>
> When I run an update (or try to install anything, I get the error stating
> "/dev/sda does not exist". That is because for example, when provisioning
> AWS nodes, the disk type is not /dev/sda but something else.
>
> My question is how do i run update grub-pc with a specific disk?  I'm
> assuming I would get the disk "name" from ansible_facts (devices), grab the
> first disk, then run something similar to  "apt install grub-pc /dev/nvme01"
>
> Is there a way to do this?  I tried the line above and it failed and I'm
> out of ideas.
>
> --
> 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/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.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/CA%2BnV635dwsmrtjGWE0bwSDmaq4_0a0A3GXS1oM2XikYJ03823A%40mail.gmail.com.


Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
Technically csv doesn’t support multiple tabs so it is not able to achieve.Thanks and Best Regards,Thanh.On 9 Aug 2023, at 19:39, Aharonu  wrote:Hi Evan Hisey,Thanks for your response.It is end user requested preferences. We don't need to avoid multiple files but segerate required data in one csv file with multiple tabs.Example,If I want to pull filesystem which are online and offline staus. We need both in one file cvs ox excel  but two different tabs.File1.cvs   Tab1: Off_fs   Tab2: On_fsOn Wed, 9 Aug 2023, 17:57 Evan Hisey, <ehi...@gmail.com> wrote:Try starting with reviewing the problem the solution is trying to solve. Why does it have too be two tabs? Is it a technical requirement or just a preference? What will be consuming the data? Can it be used as two cvs?On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:Thank you. Even I am not much aware of Python coming in advance level.It looks like big task. I will wait anyone suggest us more better wayOn Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, <ng.duct...@gmail.com> wrote:Hope can help. I am not python programmer so code may not clean.from ansible.module_utils.basic import *import sysimport osimport csvimport xlsxwriterimport globimport codecsimport pwdimport grpdef main():fields = {"csv_dir": {"required": True, "type": "str"},"output_xlsx_file": {"required": True, "type": "str"},"format_header": {"required": True, "type": "bool"},"format_error": {"required": False, "type": "list"},"format_correct": {"required": False, "type": "list"},"owner": {"required": False, "type": "str"},"group": {"required": False, "type": "str"},"split_data": {"required": False, "type": "bool"},"summary_csv_list": {"required": False, "type": "list", "default": []},}module = AnsibleModule(argument_spec=fields)wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])format_header = wb.add_format()format_header.set_bold()format_header.set_bg_color('blue')format_header.set_font_color('white')f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold': True })f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold': True })f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap': True})csv_dir = module.params['csv_dir']csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))summary_worksheets = []for summary_filename_csv in module.params['summary_csv_list']:summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)summary_sheet_title = os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]summary_ws = wb.add_worksheet(summary_sheet_title)with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:summary_table = csv.reader((l.replace('\0', '') for l in summary_csvfile))summary_num_row = 0summary_num_cols = 0summary_columns_width = []for summary_row in summary_table:if module.params['format_header'] and summary_num_row == 0:summary_ws.write_row(summary_num_row, 0, summary_row, format_header)else:modified_summary_row = []for item in summary_row:modified_summary_row.append(item)summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)summary_num_row += 1summary_num_cols = max(summary_num_cols, len(summary_row))summary_columns_width = [max(len(j), summary_columns_width[i] if len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]# Simulate autofit columnfor i, j in enumerate(summary_columns_width):column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))summary_ws.set_column(column_name, j)summary_worksheets.append(summary_ws)summary_ws.autofit()summary_ws.conditional_format('C2:C1',{'type': 'no_blanks', 'format': f2}) summary_ws.conditional_format('D2:D1',{'type': 'no_blanks', 'format': f1}) # Move the summary sheets to the first positionfor summary_ws in summary_worksheets:summary_ws.set_first_sheet()for csv_file_path in csv_file_list:if os.path.basename(csv_file_path) in module.params['summary_csv_list']:continuesheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]ws = wb.add_worksheet(sheet_title)with codecs.open(csv_file_path, 'r') as csvfile:table = csv.reader((l.replace('\0', '') for l in csvfile))num_row = 0num_cols = 0columns_width = []for row in table:if module.params['format_header'] and num_row == 0:ws.write_row(num_row, 0, row, format_header)else:modified_row = []for item in row:if ',' in item and module.params['split_data']:split_data = item.split(',')trimmed_data = [value.strip() for value in split_data]modified_row.append('\n'.join(trimmed_data))else:modified_row.append(item)ws.write_row(num_row, 0, modified_row, f3)num_row += 1num_cols = max(num_cols, l

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
am(module.params['group']).pw_uidgid = grp.getgrnam(module.params['group']).gr_gidos.chown(module.params['output_xlsx_file'], uid, gid)response = {"result": "file %s created" % (module.params['output_xlsx_file'])}module.exit_json(changed=False, meta=response)if __name__ == '__main__':main()ansible localhost -m ncs_csvtoexcel \-a "csv_dir=/ancenter/opt-tasks/TESTPROD/Monthly/Windows/Compliance/2023-06-05 \output_xlsx_file=/ancenter/opt-tasks/TESTPROD/Monthly/Windows/Compliance/2023-06-05/test.xlsx \format_header=true \ format_error=Non-Compliance \format_correct=Compliance" \ split_data: True \owner=ancenter \group=ancenter \summary_csv_list=Summary_{{todaytime}}.csv" csv_dir:description: The directory containing the csv file with csv extension.The xlsx file will contain a sheet for each csvtype: stringrequired: trueoutput_xlsx_file:description: The path of the output xlsx filetype: string required: trueformat_header:description: If true the header(the first line of each csv) will be formattedtype: boolean required: truesummary_csv_list:description: List of csv files inserted in the first sheet(s) of the workbooktype: listrequired: falseformat_error description: high light the keyword in redtype: listrequired: falseformat_correct description: high light the keyword in greentype: listrequired: falseowner: description: change owner of filetype: string required: falsegroup: description: change group of file type: stringrequired: falsesplit_data:description: If true the data in all the data row will be split with comma delimiter type: boolean required: falseThanks and Best Regards,Thanh.On 9 Aug 2023, at 18:04, Aharonu  wrote:Hi  Thanh Nguyen Duc,Thanks for quick response. May I get that reference details so I will give try for my requirement.On Wed, 9 Aug 2023, 16:29 Thanh Nguyen Duc, <ng.ducthanh1...@gmail.com> wrote:Csv i don’t think have multiple tabs. I have done with excel instead. You can use j2 template to create a csv then python to consolidate them to 1 file.On 9 Aug 2023, at 17:55, Aharonu <aharon...@gmail.com> wrote:Hi Todd and Team,Could you please help one below query? Thank you.Example, I have  file1.csv creates throught mail module as mentionedbelow. I need to create 2 tabs (data-set1, data_set2)  in file1.csv and update required data. How can I deal with this?Thank you- name: Send csv file to the user
  community.general.mail:
host: 
port: 
subject: Ansible-report
body: Hello, this is an e-mail
from: j...@example.net (Jane Jolie)
to: John Doe <j...@example.org> 
attach: ./file1.csv
  delegate_to: localhost



-- 
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/CANGEjuUuBxieKOifmcEqN9OY6Y%2BuqEdXyG2B%2BUv_eUk1FmiOVA%40mail.gmail.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/655EE3A2-3194-4219-B7D2-C7236C831F11%40gmail.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/CANGEjuWWTHkMSuTRJgKju70S9GOBSNok1oxndCkBr_aMa0vqGw%40mail.gmail.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/C95EF81F-7406-48DD-A8ED-A4C59F5B7850%40gmail.com.


Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
Csv i don’t think have multiple tabs. I have done with excel instead. You can use j2 template to create a csv then python to consolidate them to 1 file.On 9 Aug 2023, at 17:55, Aharonu  wrote:Hi Todd and Team,Could you please help one below query? Thank you.Example, I have  file1.csv creates throught mail module as mentionedbelow. I need to create 2 tabs (data-set1, data_set2)  in file1.csv and update required data. How can I deal with this?Thank you- name: Send csv file to the user
  community.general.mail:
host: 
port: 
subject: Ansible-report
body: Hello, this is an e-mail
from: j...@example.net (Jane Jolie)
to: John Doe  
attach: ./file1.csv
  delegate_to: localhost



-- 
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/CANGEjuUuBxieKOifmcEqN9OY6Y%2BuqEdXyG2B%2BUv_eUk1FmiOVA%40mail.gmail.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/655EE3A2-3194-4219-B7D2-C7236C831F11%40gmail.com.


Re: [ansible-project] Re: Failed to install package NTP

2023-07-23 Thread Thanh Nguyen Duc
Try it locally by command: yum install ntpd or chrony or dnf install chrony ansible just help you to install it remotely. The error come from your local host.On 23 Jul 2023, at 22:36, arjungoel 1995  wrote:I have tried Chrony as well but same issue persists.On Sun, Jul 23, 2023 at 1:15 AM Todd Lewis  wrote:Maybe chrony rather than ntp? What OS is your target host running?On Saturday, July 22, 2023 at 3:27:11 PM UTC-4 arjungoel 1995 wrote:Hi, I was just testing a basic playbook in Ansible. Here is the playbook code: name: Set up NTP on all servers  hosts: all  become: true  tasks:    - name: Ensure NTP is installed      yum:         name: ntp         state: present    - name: Ensure NTP is running      service:         name: ntpd         state: started         enabled: yesWhen I am running the ansible-playbook playbook.yaml command, I am getting this error:TASK [Ensure NTP is installed] fatal: [3.226.126.95]: FAILED! => {"changed": false, "failures": ["No package ntp available."], "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}PLAY RECAP 3.226.126.95               : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   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/b2c97345-e157-492e-bcff-a345002060d2n%40googlegroups.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/CALh2VPJkCPS4wjJMq967LD9HpfeH7FaQ8-%3DXL2CAkrnbuHDQtw%40mail.gmail.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/5592C7E5-287F-472E-B6D8-0A82DA794574%40gmail.com.


Re: [ansible-project] Unable to use python 3

2023-07-03 Thread Thanh Nguyen Duc
I may install python3, create a virtual env and install my ansible-core there 
then symbol link to the actual os 

Sent from my iPhone

> On 4 Jul 2023, at 08:45, Nico Kadel-Garcia  wrote:
> 
> On Fri, Jun 30, 2023 at 11:42 AM cool prat  wrote:
>> 
>> Hi @Nico Kadel-Garcia,
>> 
>> Thanks for your detailed reply.
>> 
>> I am trying to understand it. So there is some split and ansible and 
>> ansible-core is separated now. I can see in the Redhat Downloads (with 
>> whatever subscription i have)
>> the latest package for ansible for RHEL7 is `ansible-2.9.27-1.el7ae`.  No 
>> `ansible-core` i can see for RHEL7.  Can see its available for el8, el9.
>> 
>> There is no ansible package for RHEL7 that supports python3?
>> 
>> I have installed python3 on the system but unable to use it for the 
>> currently installed ansible (2.9.9).
>> Because of this (unable to use python3 on controller node) i am getting 
>> issue in using `kubernetes.core.k8s_info` (as its only support python3 and 
>> not python2). The error message you can see here - 
>> https://pastebin.com/zEx6qTXk
> 
> RHEL 7's copy of "ansible" predates the very peculiar split to
> "ansible-core", which has most of the old code, and a package called
> "ansible" which is dependent on ansible-core, takes up half a Gig of
> space, and consists of more than 100 ansible galaxy collection nodes,
> and doesn't actually contain ansible.
> 
> Jump to RHEL 8 to install ansible-core of a current release: or
> install python3 and python3 -pip, and use this:
> 
>pip3 install ansible-core --user
> 
> i actually publish hooks to build RPMs for recent backports of the
> "ansible-core" and "ansible" packages, but I gave on the obsolete RHEL
> 7 python 3 a while ago.
> 
> Nico Kadel-Garcia
> 
> 
>> Can you please tell me, what if i want to do this via .rpm way and not used 
>> pip for this?
>> 
>> Is using pip install the only way to have python3 support for ansible 
>> package on controller node on RHEL7 machine?
>> 
>> Thanks,
>>> On Friday, June 30, 2023 at 4:41:57 PM UTC+5:30 Nico Kadel-Garcia wrote:
>>> 
>>> On Thu, Jun 29, 2023 at 10:30 AM cool prat  wrote:
 
 Hi Team,
 
 I want to use python3 for using k8s module (`kubernetes.core.k8s_info`) on 
 the ansible controller node which RHEL 7.
 
 Python2 is already installed. I have installed python3.
 
 I am trying to use python3 by setting ansible_python_interpreter var but 
 its still showing that its using python version 2 in the command like 
 ansible --version.
 
 
 `ansible_python_interpreter` is already set at multiple level and even 
 after using all the options together, its still not picking up python3 and 
 giving same error.
 
 
 Have set the var ansible_python_interpreter at i) inventory, ii) playbook, 
 iii) /home/sac/ansible.cfg and iv) with -e option as well in 
 ansible-playbook` command.
 
 i) Added in inventory -
 
 # ans.ini #localhost ansible_connection=local localhost 
 ansible_python_interpreter=/opt/rh/rh-python36/root/usr/bin/python3.6
 
 ii) added in playbook
 
 - hosts: localhost connection: local gather_facts: no vars: 
 ansible_python_interpreter: /opt/rh/rh-python36/root/usr/bin/python3.6 
 tasks: . .
 
 iii) ansible.cfg
 
 # cat ansible.cfg [defaults] ANSIBLE_PYTHON_INTERPRETER = 
 /opt/rh/rh-python36/root/usr/bin/python3.6 interpreter_python = 
 /opt/rh/rh-python36/root/usr/bin/python3.6 ansible_python_interpreter = 
 /opt/rh/rh-python36/root/usr/bin/python3.6
 
 iv) Added as -e in ansible-playbook command,
 
 ansible-playbook -i ans.ini ans.yml -e 
 'ansible_python_interpreter=/opt/rh/rh-python36/root/usr/bin/python3.6'
 
 Below showing python 2.7.5
 
 # ansible --version ansible 2.9.27 config file = /etc/ansible/ansible.cfg 
 configured module search path = [u'/home/sac/.ansible/plugins/modules', 
 u'/usr/share/ansible/plugins/modules'] ansible python module location = 
 /usr/lib/python2.7/site-packages/ansible executable location = 
 /bin/ansible python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 
 4.8.5 20150623 (Red Hat 4.8.5-44)]
 
 How can i make changes so that ansible will start using python 3
 
 Thanks,
>>> 
>>> RHEL 7 published RPMs for a package called "ansible" are from before
>>> the split, to "ansibl-core" which actually has ansible, and the
>>> "ansible" package which does not contain ansible, it has a dependency
>>> on "ansible-core" and installs more than 100 additional modules from
>>> the ansible galaxy collection. It really should have been called
>>> "ansible_collections" .
>>> 
>>> You're going to hurt yourself if you keep trying to use that. In the
>>> short term, you can use "pip3 install --user ansible-core" to get a
>>> much more recent version, ansible-core 2.11. Or bump up to RHEL 8 and
>>> you can get a contemporary 

Re: [ansible-project] separate logfile per target

2023-06-30 Thread Thanh Nguyen Duc
You may create a log file with hostname, in my case i will create a log
file with name: {{inventory_hostname}}_log.xx then pull them back.


Vào Th 6, 30 thg 6, 2023 vào lúc 14:54 dulhaver via Ansible Project <
ansible-project@googlegroups.com> đã viết:

> we where wondering whether there is a method to generate logfiles per
> remote target on playbook executions?
>
> In other words ... one runs a playbook on 50 targets and gets 50 logfiles
> (1 per target) out of it.
>
> I guess another way to separate things a litte in the logs would be to use
> serial: 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/5802550.421232.1688108053966%40office.mailbox.org
> 
> .
>

-- 
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/CA%2BnV6343ds0dmXVPiQD8Uqtosuzo2LpRXcy%3DtkVdDZeSc-vEvw%40mail.gmail.com.


Re: [ansible-project] Ssh connectivity issues with ad-hoc commands, playbooks.yml, Ansible.

2023-06-15 Thread Thanh Nguyen Duc
Need to specify your target ssh user.On 15 Jun 2023, at 12:30, Prady A  wrote:You are running the script from root user. So it is trying to connect root@ip not administrator@ipOn Thu, Jun 15, 2023 at 0:58, gonzalo diaz larenas  wrote:DearGood afternoon, sorry for the inconvenience, I'm just getting started with what Ansible is, specifically learning how to optimize daily tasks in laboratories. I set up a virtualized network with a central ansible server, from where I apply ad-hoc commands and automated playbooks.yml files that point to remote hosts, I managed to configure three machines with different Debian distributions, I can connect via ssh without any problem, each machine has the corresponding public key, which I copied from the central server, that is, every time I connect via ssh it does not ask me for a password, this is a fundamental requirement when applying ad-hoc or playbook commands, with these machines I have no problems of ssh connectivity. I wanted to expand the network by adding a group called ClientWindows to the inventory file, which will host computers with Microsoft Windows 10 Pro, via ssh I can connect directly to this type of machine without any problem, I also configure them so that they do not ask me for the password when applying ad-hoc or playbook.yml commands, but here comes a problem, every time I apply an ad-hoc or playbook.yml command it gives me connectivity problems via ssh (Permission denied), when I see the connectivity error I deduce that by default ssh points to the root user, but it turns out that I am trying to connect to a machine with Windows 10 Pro that has the administrator username, the strange thing about all this is that when I connect via ssh directly (ssh administrator@x.x.x.x ) I have no problem, in fact I have configured the ssh connection so that it does not ask me for a password, I am attaching a file with the details of what I mentioned earlier, I would appreciate your guidance, regards.



-- 
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/7d00c709-bc7b-4e50-8269-937c3a572ba3n%40googlegroups.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/CAEuB3Ap9oc5GCEF-S%2B4rWJt3Uj1S7tpgcpirRP9B%3DSw%2BnD%2B7iw%40mail.gmail.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/792C4FEB-3C2E-4F71-9938-B2EC2456728C%40gmail.com.


Re: [ansible-project] ansible cannot log into server, yet I can ssh in manually

2023-06-12 Thread Thanh Nguyen Duc
Seem like it still using default configuration of ansible. Can show - and your config?On 12 Jun 2023, at 18:12, Kathy L  wrote:I am not using key authentication - userid and password.  I've checked multiple times to ensure it is the correct userid and password.  I've tried using --ask-pass as well as entering the user name and password in the hosts file.I'm using ansible version. 2.14.4 against CentOS 7 and Debian hosts.My secure log says it is looking for a public key, which I do not have set up.  The sshd_config file clearly states "PasswordAuthentication yes".I use the same user in my ansible hosts file as when I ssh in.On Monday, June 12, 2023 at 6:23:23 AM UTC-4 Thanh Nguyen Duc wrote:Are you using key authentication or password authentication? what is the secure log in your target machine? how did you configure it?Vào Th 2, 12 thg 6, 2023 vào lúc 18:17 Kathy L <lyon...@gmail.com> đã viết:As the title says, I am trying to run an ansible playbook against 10 hosts.  All 10 fail stating they cannot connect to the host via ssh.  The error sent back from ansible is:"Failed to connect to the host va ssh Received disconnect.. Too many authentication failures." Yet if I ssh into the host manually with the same account I can get into the host fine. 

I've run the setup module against these hosts with the same issue.  When I run ansible with -vvv the only thing I see is ssh trying 3 times and failing...Any ideas on what else I can try?



-- 
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9f897f2f-8c17-4678-8d97-1d45ad159982n%40googlegroups.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/f66bb50c-8270-414d-b24a-1ed83b783748n%40googlegroups.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/44149AC6-B728-4165-8111-9E185ADFB389%40gmail.com.


Re: [ansible-project] ansible cannot log into server, yet I can ssh in manually

2023-06-12 Thread Thanh Nguyen Duc
Are you using key authentication or password authentication? what is the
secure log in your target machine? how did you configure it?

Vào Th 2, 12 thg 6, 2023 vào lúc 18:17 Kathy L  đã
viết:

> As the title says, I am trying to run an ansible playbook against 10
> hosts.  All 10 fail stating they cannot connect to the host via ssh.  The
> error sent back from ansible is:
>
> "Failed to connect to the host va ssh Received disconnect.. Too many
> authentication failures."
>
> Yet if I ssh into the host manually with the same account I can get into
> the host fine.
>
> I've run the setup module against these hosts with the same issue.  When I
> run ansible with -vvv the only thing I see is ssh trying 3 times and
> failing...
>
> Any ideas on what else I can try?
>
> --
> 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/9f897f2f-8c17-4678-8d97-1d45ad159982n%40googlegroups.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/CA%2BnV6358pGbyirk_oZ74Yj1g59XqVaY6wLD5MeYoNsb4OBncZg%40mail.gmail.com.


Re: [ansible-project] install vmware tools via ansible playbook (winrm)

2023-03-10 Thread Thanh Nguyen Duc
Does command work locally? If can then you may try to create a bat file then trigger it instead?Thanks and Best Regards,Thanh.On 11 Mar 2023, at 07:29, Will McDonald  wrote:It's hard to tell from the mail formatted commands but thoughts off the top of my head:1. /S /v"/qn looks like it might need an additional space: /v "/qn2. Have you tried to register the output of the task and then subsequently inspect that? If so... what's the output?3. Have you tried using the argv parameter to see if that helps C:\VMware-tools-12.1.5-20735119-x86_64.exe parse its arguments more cleanly?4. If you drop that heavily quoted command line into a powershell or batch/command instead and copy then call it... what happens? (Purely from a debug/problem reduction perspective?On Fri, 10 Mar 2023 at 23:11, Shay Cohen  wrote:.I am trying to install a vmare tools on windows machine but noting happenI manage to copy the file but when I am trying to install I don't see any error or installation running in the background. hosts: all  tasks:    - name: Copy a single file vmare-tools      ansible.windows.win_copy:        src: /etc/ansible/roles/vmware_tools/files/VMware-tools-12.1.5-20735119-x86_64.exe        dest: C:\VMware-tools-12.1.5-20735119-x86_64.exe    - name: Install vmware tools      ansible.windows.win_command: '"C:\VMware-tools-12.1.5-20735119-x86_64.exe" /S /v"/qn REBOOT=R ADDLOCAL=ALL REMOVE=AppDefense,FileIntrospection,NetworkIntrospection,Hgfs" /ru SYSTEM /rl HIGHEST /l C:\VMwareToolsInstall.log'



-- 
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/38f6a909-538a-4848-997d-163b94c238aan%40googlegroups.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/CAKtKohRHFtszNSkE5i5frMkP8z1yhD_qyD9ZU_fOatzbjuAoNg%40mail.gmail.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/7431A3FB-483F-4A99-B732-B828D01ABF3D%40gmail.com.


Re: [ansible-project] Resizing the Vmware VMDK Through Ansible script

2023-02-14 Thread Thanh Nguyen Duc
I don’t think vmware support to resize the disk by decrease the volume size directly. Likely the disk shrink already removed some file systems from OS and cause the OS not able to boot up. Thanks and Best Regards,Thanh.On 14 Feb 2023, at 15:30, Duy Huynh Đỗ  wrote:
Dear
Abhijeet Kasurde,Thanks a lot for
 your script, the disk upgrade on vcenter was successful but windows os 
can't boot again (blue screen) after disk is expanded by scriptI am using ansible 2.10.8, vcenter 8Please help me ! Vào lúc 19:15:19 UTC+7 ngày Thứ Tư, 10 tháng 6, 2020, Tony Wong đã viết:Interested in this too.  I got a windows VM with only C drive. I want to resize from 60GB to 70GBhow do i set up the playbookOn Tue, Jun 9, 2020 at 10:18 PM Abhijeet Kasurde  wrote:What kind of tasks do you need to run on the OS level? You can either use `vmware_vm_shell` to run command or add that VM as ansible host using `add_host` and run command in subsequent plays.On Wed, Jun 10, 2020 at 10:44 AM JC JC  wrote:



















HI Abhijeet,

 

Thanks a lot for your script, I need
one more help that after VM HDD space increased on VM level, we need to perform
some task on OS level to see the additional disk space, do you have any ansible
script or any help from you.





CheersShiva Shankar SOn Tue, 9 Jun 2020 at 16:36, Abhijeet Kasurde  wrote:Hi Shiva,You can do like this -  hosts: localhost  gather_facts: false  vars_files:    - vcenter_vars.yml  tasks:  - name: Resize to 10GB from 4GB    vmware_guest_disk:      validate_certs: False      hostname: '{{ vcenter_hostname }}'      username: '{{ vcenter_username }}'      password: '{{ vcenter_password }}'      datacenter: Asia-Datacenter1      name: vm_8046      disk:        - datastore: "ds_171_2"          scsi_controller: 0          scsi_type: 'paravirtual'          size_gb: 10          state: present          unit_number: 0TASK [Resize to 10GB from 4GB] **task path: /Volumes/data/src/playbooks/vmware/vmware_guest_disk_resize.yml:7redirecting (type: modules) ansible.builtin.vmware_guest_disk to community.vmware.vmware_guest_diskchanged: [localhost] => {"changed": true, "disk_changes": {"0": "Disk size increased."}, "disk_data": {"0": {"backing_datastore": "ds_171_2", "backing_disk_mode": "persistent", "backing_eagerlyscrub": false, "backing_filename": "[ds_171_2] vm_8046/vm_8046.vmdk", "backing_thinprovisioned": false, "backing_writethrough": false, "capacity_in_bytes": 10737418240, "capacity_in_kb": 10485760, "controller_key": 1000, "iolimit_limit": -1, "iolimit_shares_level": "normal", "iolimit_shares_limit": 1000, "key": 2000, "label": "Hard disk 1", "shares_level": "normal", "shares_limit": 1000, "summary": "10,485,760 KB", "unit_number": 0}}}If you have multiple disks, you need to gather information about all disk and pass it to vmware_guest_disk before making any changes.You can take the help of this playbook https://github.com/Akasurde/ansible-reproducers/blob/master/55999/i55999.yml. (This playbook adds a new disk to configuration, but can be modified to resize disk as well)On Tue, Jun 9, 2020 at 11:48 AM JC JC  wrote:

Hi Team,

 

I'm looking for
ansible script to resize my Existing Virtual machine Primary Hard disk (VMDK).

 

Cheers

Shiva Shankar S





-- 
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/43fc8a33-8db1-46bb-8875-ca8333c3caeeo%40googlegroups.com.
-- Thanks,Abhijeet Kasurde



-- 
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFwWkHro90sG79kxBkKsFgG-Bchne0v6q0TnLnEtiOn4_6hGWw%40mail.gmail.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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANGdo7_U_4sFoY_izPFRwAbWgUEMeYEv8kw4Y8MDo0g%2Bv6-mnw%40mail.gmail.com.
-- Thanks,Abhijeet Kasurde



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





-- 
You received this 

Re: [ansible-project] Identify most recent directory in a directory.

2022-12-22 Thread Thanh Nguyen Duc
I don’t think you can achieve what you want if the file keep generating. 
Ansible is not real time monitor/scanning. The most recently at the point of 
time when you trigger only. 

Thanks and Best Regards,

Thanh.

> On 23 Dec 2022, at 11:55, Nico Kadel-Garcia  wrote:
> 
> On Thu, Dec 1, 2022 at 7:10 PM Vladimir Botka  wrote:
>> 
>> Use Ansible module *find* and sort the directories by *ctime*. For
>> example, given the tree
> 
> This is only reliable if nothing else writes anything else in that
> tree between the first command, tand the "tree" command.
> 
> 
>> shell> tree /tmp/test
>> /tmp/test
>> ├── 2022-12-01_1701
>> ├── 2022-12-01_1702
>> └── 2022-12-01_1703
>> 
>> Declare the variable
>> 
>>  last_dir: "{{ (out.files|sort(attribute='ctime')|last).path }}"
>> 
>> The tasks below
>> 
>>- find:
>>path: /tmp/test
>>file_type: directory
>>  register: out
>>- debug:
>>var: last_dir
>> 
>> give
>> 
>>  last_dir: /tmp/test/2022-12-01_1703
>> 
>> If you want to take look at the *ctime*
>> 
>>  path_ctime: "{{ out.files|json_query('[].[path, ctime]') }}"
>> 
>> give
>> 
>>  path_ctime:
>>- [/tmp/test/2022-12-01_1702, 1669938403.313556]
>>- [/tmp/test/2022-12-01_1701, 1669938401.2335565]
>>- [/tmp/test/2022-12-01_1703, 1669938405.0495553]
>> 
>> --
>> Vladimir Botka
>> 
>> --
>> 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/20221202011038.0ed02422%40gmail.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/CAOCN9rw4aus7R6ZtB6z-oOQeFDa8BgwDyhFPcqVUXqdcLJi9yg%40mail.gmail.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/3A7008EA-6584-4E5D-8CEE-3F674C132306%40gmail.com.


Re: [ansible-project] Identify most recent directory in a directory.

2022-12-01 Thread Thanh Nguyen Duc
Is it the shell script also be triggered via ansible? If yes then you can 
register the path and work with it later. If not then do you know roughly when 
script be triggered then can just use shell command to find the directory with 
created date.

Sent from my iPhone

> On 2 Dec 2022, at 05:57, Jason Wood  wrote:
> 
> After performing a shell script, a new directory is created and I need to 
> work with that directory, but I don't know the name.
> 
> How can I get the name of the most recent directory created?
> 
> The name will be formatted like 2022-12-01_1702, so the directory I need will 
> be the last if sorted alphanumerically, if that helps.
> 
> I found resources for looking at files, but not directories. If it's 
> necessary to find this directory based on the creation date of its contents, 
> there are files located at [dirname]/Databases/Filename.xxx
> 
> 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/3b559b55-8658-4df0-b32b-a227def8ca40n%40googlegroups.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/7E74CF9E-4D72-480F-805B-D1F6735E8F18%40gmail.com.


Re: [ansible-project] Winrm configuration issue

2021-07-22 Thread Thanh Nguyen Duc
Hi Jean,

It is allowed. I have tried from other server to this server and it worked 
fine. Account has full admin right to local server and no deny policy be 
granted. Seem like sth wrong with the cert or ssl from my client because when i 
tried openssl s_client myhost:5986, the cert never showed.

Thanks and Regards,

Thanh.

Sent from my iPhone

> On 22 Jul 2021, at 18:28, 'Jean-Yves LENHOF' via Ansible Project 
>  wrote:
> 
> 
> Hi,
> 
> Is the account local and your GPO (seems that there are some) does'nt allow 
> to log in with this account remotely ?
> 
> Regards,
> 
> JYL
> 
> 
> 
> Le 22/07/2021 à 12:09, Thanh Nguyen Duc a écrit :
>> Hi 
>> 
>> I have tried to reset password, telnet to client. All ok. Even tried to use 
>> the service account to login server locally and successful.
>> 
>> Thanks and Regards,
>> 
>> Thanh.
>> 
>> Sent from my iPhone
>> 
>>> On 22 Jul 2021, at 17:49, Kundan Singh  wrote:
>>> 
>>> 
>>> Please try reseting password and check port on server also validate 
>>> connectivity work from controller server
>>> 
>>> Regards
>>> Kundan singh
>>> 
>>> On Thu, Jul 22, 2021, 2:13 PM Thanh Nguyen Duc  
>>> wrote:
>>>> Hi experts,
>>>> 
>>>> I have an ansible server managing a lot of windows servers. Recently I 
>>>> encountered an issue with a few client with the error below. 
>>>> 
>>>> -- 
>>>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.com.
>>>> 
>>>> 
>>>> I have tried many things like verify the cert with wirm, compare tls, ssl… 
>>>> but no difference with the working one. All look good. Hope someone 
>>>> encountered it before and manage to solve it
>>>> 
>>>> -- 
>>>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.com.
>>>> 
>>>> 
>>>> Thank you so much for your advice in advance.
>>>> 
>>>> Best Regards,
>>>> 
>>>> Thanh.
>>>> 
>>>> -- 
>>>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.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/CADGcVU3fVVpibb70zN3BFXVYCfvS%3DVm0v%2BDoxCM1rvx4Jd5nfA%40mail.gmail.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/B5563EC8-D0BE-40BA-AB69-C61D55655EBD%40gmail.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/c6955ad2-bb63-4724-d26f-eaaccaefce30%40lenhof.eu.org.

-- 
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/A16CE916-78DA-4B4F-A925-AE1A1D6AB5B5%40gmail.com.


Re: [ansible-project] Winrm configuration issue

2021-07-22 Thread Thanh Nguyen Duc
Hi 

I have tried to reset password, telnet to client. All ok. Even tried to use the 
service account to login server locally and successful.

Thanks and Regards,

Thanh.

Sent from my iPhone

> On 22 Jul 2021, at 17:49, Kundan Singh  wrote:
> 
> 
> Please try reseting password and check port on server also validate 
> connectivity work from controller server
> 
> Regards
> Kundan singh
> 
>> On Thu, Jul 22, 2021, 2:13 PM Thanh Nguyen Duc  
>> wrote:
>> Hi experts,
>> 
>> I have an ansible server managing a lot of windows servers. Recently I 
>> encountered an issue with a few client with the error below. 
>> 
>> -- 
>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.com.
>> 
>> 
>> I have tried many things like verify the cert with wirm, compare tls, ssl… 
>> but no difference with the working one. All look good. Hope someone 
>> encountered it before and manage to solve it
>> 
>> -- 
>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.com.
>> 
>> 
>> Thank you so much for your advice in advance.
>> 
>> Best Regards,
>> 
>> Thanh.
>> 
>> -- 
>> 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/696E3CDB-CFCA-4298-9765-CA4589D5B258%40gmail.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/CADGcVU3fVVpibb70zN3BFXVYCfvS%3DVm0v%2BDoxCM1rvx4Jd5nfA%40mail.gmail.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/B5563EC8-D0BE-40BA-AB69-C61D55655EBD%40gmail.com.


Re: [ansible-project] Winrm configuration issue

2021-07-22 Thread Thanh Nguyen Duc
Hi Antony,

Sorry, i have attached the text file.

Thanks and Regards,

Thanh.

Vào Th 5, 22 thg 7, 2021 vào lúc 16:47 Antony Stone <
antony.st...@ansible.open.source.it> đã viết:

> On Thursday 22 July 2021 at 10:43:35, Thanh Nguyen Duc wrote:
>
> > Hi experts,
> >
> > I have an ansible server managing a lot of windows servers. Recently I
> > encountered an issue with a few client with the error below.
>
> Your photographs are very difficult to read.
>
> Please copy and paste text instead.
>
>
> Antony.
>
> --
> Tinned food was developed for the British Navy in 1813.
>
> The tin opener was not invented until 1858.
>
>Please reply to the
> list;
>  please *don't* CC
> 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/CA%2BnV635CxqG-jxeWSdqp-9S1WGXhJ9ebkSAoxfNp%3D5_CXqm%3DLw%40mail.gmail.com.
[ancenter@T00033BRNM018 ancenter]$ sudo ansible T00938BENW001 -m win_ping -i 
/etc/ansible/inventory/inventory_XXX.yml -v
ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 
(Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/inventory/inventory_XXX.yml as it did 
not pass its verify_file() method
script declined parsing /etc/ansible/inventory/inventory_XXX.yml as it did not 
pass its verify_file() method
Skipping empty key (hosts) in group (linhosts)
Parsed /etc/ansible/inventory/inventory_XXX.yml inventory source with yaml 
plugin
Loading callback plugin minimal of type stdout, v2.0 from 
/usr/lib/python2.7/site-packages/ansible/plugins/callback/minimal.pyc
META: ran handlers
Using module file 
/usr/lib/python2.7/site-packages/ansible/modules/windows/win_ping.ps1
Pipelining is enabled.
 ESTABLISH WINRM CONNECTION FOR USER: serviceaccoun-ansible on 
PORT 5986 TO T00938BENW001
 WINRM CONNECT: transport=basic 
endpoint=https://T00938BENW001:5986/wsman
 WINRM CONNECTION ERROR: ('Connection aborted.', error(104, 
'Connection reset by peer'))
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", 
line 413, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001)  # UTF-8
  File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 157, in 
open_shell
res = self.send_message(xmltodict.unparse(req))
  File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 234, in 
send_message
resp = self.transport.send_message(message)
  File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 256, in 
send_message
response = self._send_message_request(prepared_request, message)
  File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 261, in 
_send_message_request
response = self.session.send(prepared_request, 
timeout=self.read_timeout_sec)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 646, in 
send
r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 498, in 
send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
T00938BENW001 | UNREACHABLE! => {
"changed": false,
"msg": "basic: ('Connection aborted.', error(104, 'Connection reset by 
peer'))",
"unreachable": true
}


[ancenter@T00033BRNM018 ancenter]$  openssl s_client -connect T00938BENW001:5986
CONNECTED(0003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 289 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol  : TLSv1.2
Cipher: 
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg   : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
Start Time: 1626944144
Timeout   : 300 (sec)
Verify return code: 0 (ok)
---

##
[ancenter@T00033BRNM018 ancenter]$  openssl s_client -connect 
T00938BENW0

Re: [ansible-project] Based on vendor have to execute playbook

2021-06-16 Thread Thanh Nguyen Duc
You can see the vendor when gather facts and set condition when vendor = hp

Sent from my iPhone

> On 17 Jun 2021, at 08:32, Wei-Yen Tan  wrote:
> 
> 
> Use conditionals as in when 
> 
> Get Outlook for iOS
> From: ansible-project@googlegroups.com  on 
> behalf of NAVEEN 
> Sent: Thursday, June 17, 2021 12:28:54 PM
> To: ansible-project@googlegroups.com 
> Subject: [ansible-project] Based on vendor have to execute playbook
>  
> Hello Team ,
> 
> I am having 3 vendors Ex :HP ,DELL ,Lenovo 
> i have 3 separate  playbooks
> Now  i want to execute those  based on vendor .If it is HP it should call Hp 
> Playbook Likewise..Can some one please help.
> 
> -- 
> Regards
> Naveen 
> -- 
> 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/CAB_%3D4oa%2BVbabwdnAanxWn25SPkK-yaoOpw3eyTP1%2BQXSRdw79g%40mail.gmail.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/SYBPR01MB561684E21FFDBBA53243244EAD0E9%40SYBPR01MB5616.ausprd01.prod.outlook.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/3DC9B8A4-309A-4A97-9B72-D56CDAEB3D7C%40gmail.com.


Re: [ansible-project] Ping Host from Ansible Server

2021-06-16 Thread Thanh Nguyen Duc
For windows and linux, i have created a playbook to run everyday at 1am to 
check whether the host is reachable or not and data will be written to jinja 
template with html format for the final report.

Sent from my iPhone

> On 16 Jun 2021, at 23:53, Brian Coca  wrote:
> 
> for network appliances use
> https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html
> instead
> 
> 
> -- 
> --
> 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/CACVha7eZd5MqM-MpZvHpcOv7Ao5EeYR61N-1VftoScHir7hanw%40mail.gmail.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/D5718DFB-7156-4DD3-B542-C781B9E75F76%40gmail.com.


Re: [ansible-project] docker installation problems

2021-04-26 Thread Thanh Nguyen Duc
Sorry, it should be become: true
By default it will elevate the account to root. You may need to pass 
become_user_pass as well.

Sent from my iPhone

> On 26 Apr 2021, at 18:30, rebecca acheampong  wrote:
> 
> I just added become_user: root but the same problem
> 
>> On Monday, April 26, 2021 at 1:27:33 PM UTC+3 ng.duct...@gmail.com wrote:
>> Look like you need to add become_user option there
>> 
>> Sent from my iPhone
>> 
 On 26 Apr 2021, at 18:21, rebecca acheampong  wrote:
 
>>> I am using ansible to install a docker but I get this error. How can i 
>>> solve this please?
>> 
>>> Please help me, this installation has taken me a whole week
>>> 
>>> Control node is ubuntu server 20.04
>>> Target node is ubuntu desktop 18.04 on vmware esxi
>>> 
>>> this is my playbook: 
>>> ---
>>> - name: installing docker on ubuntu
>>>   hosts: localhost
>>>   remote_user: "{{ remote_user_name }}"
>>>   gather_facts: no
>>>   vars_files:
>>>  - var_docker.yml
>>>   vars:
>>>remote_user_name: cyber01
>>>apt_repo_data: "deb [arch=amd64]
>>>https://download.docker.com/linux/ubuntu xenial stable"
>>>apt_gpg_key: https://download.docker.com/linux/ubuntu/gpg
>>>   tasks:
>>> - vmware_guest:
>>> hostname: "{{ VMWARE_HOST }}"
>>> username: "{{ VMWARE_USER }}"
>>> password: "{{ VMWARE_PASSWORD }}"
>>> validate_certs: no
>>> folder: /ha-datacenter/vm/
>>> name: my_vm_01
>>> - name: adding docker gpg key
>>>   apt_key:
>>> url: "{{ apt_gpg_key }}"
>>> state: present
>>> - name: add docker repository
>>>   apt_repository:
>>>repo: "{{ apt_repo_data }}"
>>> state: present
>>> - name: installing docker-ce
>>>   apt:
>>> name: docker-ce
>>> state: present
>>> update_cache: yes
>>> - name: install python-pip
>>>   apt:
>>> name: python-pip
>>> state: present
>>> - name: install docker-py
>>>   pip:
>>> name: docker-py
>>> state: present
>>> 
>>> run playbook: ansible-playbook -i hosts docker_contairner.yml
>>> 
>>> PLAY [installing docker on ubuntu] 
>>> *
>>> 
>>> TASK [vmware_guest] 
>>> 
>>> ok: [my_vm_01]
>>> 
>>> TASK [adding docker gpg key] 
>>> ***
>>> fatal: [my_vm_01]: FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key 
>>> add -", "msg": "Warning: apt-key output should not be parsed (stdout is not 
>>> a terminal)\nE: This command can only be used by root.", "rc": 1, "stderr": 
>>> "Warning: apt-key output should not be parsed (stdout is not a 
>>> terminal)\nE: This command can only be used by root.\n", "stderr_lines": 
>>> ["Warning: apt-key output should not be parsed (stdout is not a terminal)", 
>>> "E: This command can only be used by root."], "stdout": "", "stdout_lines": 
>>> []}
>>> 
>> 
>>> -- 
>>> 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-proje...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/eac60358-57e0-4f9f-ad03-377ec881f6e2n%40googlegroups.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/0eea9d03-612d-4608-b6cd-04cf044d1885n%40googlegroups.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/AA7D7F8F-A159-4A79-83B4-AF7C2D469FD3%40gmail.com.


Re: [ansible-project] Facing issues with ssh connection as user root

2021-04-26 Thread Thanh Nguyen Duc
Did you execute your playbook with sudo? If with sudo then you may need to ssh 
copy key again for root account to target machine. And Can try to add - 
then post the result?

Sent from my iPhone

> On 26 Apr 2021, at 18:37, Hasini P  wrote:
> 
> 
> yes, I am able to ping-pong with my userID.. ssh password-less connectivity 
> was established from control server to remote server with my ID
> 
> 
>> On Monday, 26 April 2021 at 16:05:34 UTC+5:30 ng.duct...@gmail.com wrote:
>> Sorry, first of all, are you able to ping your server by ansible yourserver 
>> -m ping? Have you done to transfer your public key to client?
>> 
>> Sent from my iPhone
>> 
 On 26 Apr 2021, at 18:32, Hasini P  wrote:
 
>>> Thanks, I tried different possibilities including your suggestion as 
>>> below., but it didnt work
>> 
>>> 
>>> ---
>>> - name: test
>>>   hosts: all 
>>>   tasks:
>>>   - name: sample shell task to check the userID
>>> shell: echo `whoami`
>>> become: yes
>>> 
 On Monday, 26 April 2021 at 15:59:20 UTC+5:30 ng.duct...@gmail.com wrote:
 I think just become_user: yes may solve your issue.
 
 Sent from my iPhone
 
>> On 26 Apr 2021, at 18:26, Hasini P  wrote:
>> 
> 
 
> 
> Team,  Can someone sort this out please.. We are using 2.8.18 version of 
> ansible on our control node. 
> I am facing error when trying to perform ping-pong with ansible as 
> become_user root (as pasted below). On the remote server, the user is 
> having access to run sudo commands and user can become root by running 
> sudo su -  
>  (with become disabled, connection is working fine to any remote_user)
>  
> Error ---_> 
> 1x.xx.xxx.xx | FAILED! => {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": false,
> "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 
> 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
> /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: 
> Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: 
> mux_client_hello_exchange: master version 4\r\ndebug3: 
> mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: 
> mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
> entering\r\ndebug3: mux_client_request_alive: done pid = 31364\r\ndebug3: 
> mux_client_request_session: session request sent\r\ndebug1: 
> mux_client_request_session: master session id: 2\r\ndebug3: 
> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: 
> Received exit status from master 1\r\nShared connection to 1x.xx.xxx.xx 
> closed.\r\n",
> "module_stdout": "",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
> "rc": 1
>  
> I have used the below privilege escalation and tried ssh_connection 
> parameters in ansible config file
> [privilege_escalation]
> become=True
> become_method=sudo
> become_user=root
> become_ask_pass=True
>  
> [ssh_connection]
> ssh_args='-C -o ControlMaster=auto -o ControlPersist=60s'
> pipelining=False
> 
> On remote server, we have 2.7.5 version of python
> python3 --version
> -bash: python3: command not found
> $ python --version
> Python 2.7.5
> $ which python
> /bin/python
> sudo which python
> SUDO requires you to enter your login password :
> /bin/python
> 
> 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-proje...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/f3f80daf-fd7c-47b8-8950-704d8f6d4762n%40googlegroups.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-proje...@googlegroups.com.
>> 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/98908b1a-44f0-4ab7-859e-c44fb6c36bbbn%40googlegroups.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/9da37eca-0cd5-4a2a-ae8f-1523fda3a382n%40googlegroups.com.

-- 
You received this message because you are subscribed to 

Re: [ansible-project] Facing issues with ssh connection as user root

2021-04-26 Thread Thanh Nguyen Duc
Sorry, first of all, are you able to ping your server by ansible yourserver -m 
ping? Have you done to transfer your public key to client?

Sent from my iPhone

> On 26 Apr 2021, at 18:32, Hasini P  wrote:
> 
> Thanks, I tried different possibilities including your suggestion as below., 
> but it didnt work
> ---
> - name: test
>   hosts: all 
>   tasks:
>   - name: sample shell task to check the userID
> shell: echo `whoami`
> become: yes
> 
>> On Monday, 26 April 2021 at 15:59:20 UTC+5:30 ng.duct...@gmail.com wrote:
>> I think just become_user: yes may solve your issue.
>> 
>> Sent from my iPhone
>> 
 On 26 Apr 2021, at 18:26, Hasini P  wrote:
 
>>> 
>> 
>>> 
>>> Team,  Can someone sort this out please.. We are using 2.8.18 version of 
>>> ansible on our control node. 
>>> I am facing error when trying to perform ping-pong with ansible as 
>>> become_user root (as pasted below). On the remote server, the user is 
>>> having access to run sudo commands and user can become root by running sudo 
>>> su -  
>>>  (with become disabled, connection is working fine to any remote_user)
>>>  
>>> Error ---_> 
>>> 1x.xx.xxx.xx | FAILED! => {
>>> "ansible_facts": {
>>> "discovered_interpreter_python": "/usr/bin/python"
>>> },
>>> "changed": false,
>>> "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 
>>> 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
>>> /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: 
>>> Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: 
>>> mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
>>> request forwardings: 0 local, 0 remote\r\ndebug3: 
>>> mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
>>> entering\r\ndebug3: mux_client_request_alive: done pid = 31364\r\ndebug3: 
>>> mux_client_request_session: session request sent\r\ndebug1: 
>>> mux_client_request_session: master session id: 2\r\ndebug3: 
>>> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
>>> exit status from master 1\r\nShared connection to 1x.xx.xxx.xx closed.\r\n",
>>> "module_stdout": "",
>>> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
>>> "rc": 1
>>>  
>>> I have used the below privilege escalation and tried ssh_connection 
>>> parameters in ansible config file
>>> [privilege_escalation]
>>> become=True
>>> become_method=sudo
>>> become_user=root
>>> become_ask_pass=True
>>>  
>>> [ssh_connection]
>>> ssh_args='-C -o ControlMaster=auto -o ControlPersist=60s'
>>> pipelining=False
>>> 
>>> On remote server, we have 2.7.5 version of python
>>> python3 --version
>>> -bash: python3: command not found
>>> $ python --version
>>> Python 2.7.5
>>> $ which python
>>> /bin/python
>>> sudo which python
>>> SUDO requires you to enter your login password :
>>> /bin/python
>>> 
>>> 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-proje...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/f3f80daf-fd7c-47b8-8950-704d8f6d4762n%40googlegroups.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/98908b1a-44f0-4ab7-859e-c44fb6c36bbbn%40googlegroups.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/E9FC98B7-5A44-44E0-9DCB-2338B9D21D28%40gmail.com.


Re: [ansible-project] Facing issues with ssh connection as user root

2021-04-26 Thread Thanh Nguyen Duc
Sorry, just become: true may solve, by default it always become root already

Sent from my iPhone

> On 26 Apr 2021, at 18:29, Thanh Nguyen Duc  wrote:
> 
> I think just become_user: yes may solve your issue.
> 
> Sent from my iPhone
> 
>>> On 26 Apr 2021, at 18:26, Hasini P  wrote:
>>> 
>> 
>> Team,  Can someone sort this out please.. We are using 2.8.18 version of 
>> ansible on our control node. 
>> I am facing error when trying to perform ping-pong with ansible as 
>> become_user root (as pasted below). On the remote server, the user is having 
>> access to run sudo commands and user can become root by running sudo su -  
>>  (with become disabled, connection is working fine to any remote_user)
>>  
>> Error ---_> 
>> 1x.xx.xxx.xx | FAILED! => {
>> "ansible_facts": {
>> "discovered_interpreter_python": "/usr/bin/python"
>> },
>> "changed": false,
>> "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 
>> 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
>> /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: 
>> Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: 
>> mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
>> request forwardings: 0 local, 0 remote\r\ndebug3: 
>> mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
>> entering\r\ndebug3: mux_client_request_alive: done pid = 31364\r\ndebug3: 
>> mux_client_request_session: session request sent\r\ndebug1: 
>> mux_client_request_session: master session id: 2\r\ndebug3: 
>> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
>> exit status from master 1\r\nShared connection to 1x.xx.xxx.xx closed.\r\n",
>> "module_stdout": "",
>> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
>> "rc": 1
>>  
>> I have used the below privilege escalation and tried ssh_connection 
>> parameters in ansible config file
>> [privilege_escalation]
>> become=True
>> become_method=sudo
>> become_user=root
>> become_ask_pass=True
>>  
>> [ssh_connection]
>> ssh_args='-C -o ControlMaster=auto -o ControlPersist=60s'
>> pipelining=False
>> 
>> On remote server, we have 2.7.5 version of python
>> python3 --version
>> -bash: python3: command not found
>> $ python --version
>> Python 2.7.5
>> $ which python
>> /bin/python
>> sudo which python
>> SUDO requires you to enter your login password :
>> /bin/python
>> 
>> 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/f3f80daf-fd7c-47b8-8950-704d8f6d4762n%40googlegroups.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/91B09FE0-637E-4B3E-A40D-41251F5807E0%40gmail.com.


Re: [ansible-project] Facing issues with ssh connection as user root

2021-04-26 Thread Thanh Nguyen Duc
I think just become_user: yes may solve your issue.

Sent from my iPhone

> On 26 Apr 2021, at 18:26, Hasini P  wrote:
> 
> 
> Team,  Can someone sort this out please.. We are using 2.8.18 version of 
> ansible on our control node. 
> I am facing error when trying to perform ping-pong with ansible as 
> become_user root (as pasted below). On the remote server, the user is having 
> access to run sudo commands and user can become root by running sudo su -  
>  (with become disabled, connection is working fine to any remote_user)
>  
> Error ---_> 
> 1x.xx.xxx.xx | FAILED! => {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": false,
> "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 
> 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
> /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: 
> Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: 
> mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
> request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: 
> entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: 
> mux_client_request_alive: done pid = 31364\r\ndebug3: 
> mux_client_request_session: session request sent\r\ndebug1: 
> mux_client_request_session: master session id: 2\r\ndebug3: 
> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
> exit status from master 1\r\nShared connection to 1x.xx.xxx.xx closed.\r\n",
> "module_stdout": "",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
> "rc": 1
>  
> I have used the below privilege escalation and tried ssh_connection 
> parameters in ansible config file
> [privilege_escalation]
> become=True
> become_method=sudo
> become_user=root
> become_ask_pass=True
>  
> [ssh_connection]
> ssh_args='-C -o ControlMaster=auto -o ControlPersist=60s'
> pipelining=False
> 
> On remote server, we have 2.7.5 version of python
> python3 --version
> -bash: python3: command not found
> $ python --version
> Python 2.7.5
> $ which python
> /bin/python
> sudo which python
> SUDO requires you to enter your login password :
> /bin/python
> 
> 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/f3f80daf-fd7c-47b8-8950-704d8f6d4762n%40googlegroups.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/E167C2F4-644F-4FA2-928B-F91B020678F5%40gmail.com.


Re: [ansible-project] docker installation problems

2021-04-26 Thread Thanh Nguyen Duc
Look like you need to add become_user option there

Sent from my iPhone

> On 26 Apr 2021, at 18:21, rebecca acheampong  wrote:
> 
> I am using ansible to install a docker but I get this error. How can i solve 
> this please?
> Please help me, this installation has taken me a whole week
> 
> Control node is ubuntu server 20.04
> Target node is ubuntu desktop 18.04 on vmware esxi
> 
> this is my playbook: 
> ---
> - name: installing docker on ubuntu
>   hosts: localhost
>   remote_user: "{{ remote_user_name }}"
>   gather_facts: no
>   vars_files:
>  - var_docker.yml
>   vars:
>remote_user_name: cyber01
>apt_repo_data: "deb [arch=amd64]
>https://download.docker.com/linux/ubuntu xenial stable"
>apt_gpg_key: https://download.docker.com/linux/ubuntu/gpg
>   tasks:
> - vmware_guest:
> hostname: "{{ VMWARE_HOST }}"
> username: "{{ VMWARE_USER }}"
> password: "{{ VMWARE_PASSWORD }}"
> validate_certs: no
> folder: /ha-datacenter/vm/
> name: my_vm_01
> - name: adding docker gpg key
>   apt_key:
> url: "{{ apt_gpg_key }}"
> state: present
> - name: add docker repository
>   apt_repository:
>  repo: "{{ apt_repo_data }}"
> state: present
> - name: installing docker-ce
>   apt:
> name: docker-ce
> state: present
> update_cache: yes
> - name: install python-pip
>   apt:
> name: python-pip
> state: present
> - name: install docker-py
>   pip:
> name: docker-py
> state: present
> 
> run playbook: ansible-playbook -i hosts docker_contairner.yml
> 
> PLAY [installing docker on ubuntu] 
> *
> 
> TASK [vmware_guest] 
> 
> ok: [my_vm_01]
> 
> TASK [adding docker gpg key] 
> ***
> fatal: [my_vm_01]: FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key add 
> -", "msg": "Warning: apt-key output should not be parsed (stdout is not a 
> terminal)\nE: This command can only be used by root.", "rc": 1, "stderr": 
> "Warning: apt-key output should not be parsed (stdout is not a terminal)\nE: 
> This command can only be used by root.\n", "stderr_lines": ["Warning: apt-key 
> output should not be parsed (stdout is not a terminal)", "E: This command can 
> only be used by root."], "stdout": "", "stdout_lines": []}
> 
> -- 
> 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/eac60358-57e0-4f9f-ad03-377ec881f6e2n%40googlegroups.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/E99A3916-3584-401F-874D-210A83FEE7C2%40gmail.com.


Re: [ansible-project] Re: Windows machine not pinging.

2020-10-13 Thread Thanh Nguyen Duc
You are using domain account or local account?

Vào Th 2, 12 thg 10, 2020 vào lúc 17:18 uday kiran 
đã viết:

> But the credentials are correct.
>
> On Saturday, 10 October 2020 at 05:25:37 UTC+5:30 jbor...@gmail.com wrote:
>
>> The ping and win_ping modules aren't doing an ICMP ping, they are
>> checking to see if Ansible can connect to the host and execute a very basic
>> module. In your case it's able to connect to the host but it's enable to
>> authenticate using the credentials you have specified. See
>> https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#http-401-credentials-rejected
>> for a list of reasons why it might be rejecting your credentials.
>>
>> On Friday, October 9, 2020 at 7:20:56 PM UTC+10 uday1...@gmail.com wrote:
>>
>>> ICMP protocol is emabled on remote machine.
>>> Remote desktop is also enabled.
>>> winrm and enable-psremoting also enabled
>>>
>>> Ran, below commands also.
>>> winrm set winrm/config/client/auth '@{Basic="true"}'
>>> winrm set winrm/config/service/auth '@{Basic="true"}'
>>>
>>> Able to ping the remote windows serer 2019 machine from ansible server
>>> ubuntu machine.
>>>
>>> But when I ran a ping test, win_ping from ansible, getting below error.
>>> adminuser@ansible-server:~/Desktop/DM$ ansible windows -m win_ping -vvv
>>> -i inventory.yml
>>> ansible 2.9.12
>>>   config file = /etc/ansible/ansible.cfg
>>>   configured module search path =
>>> [u'/home/adminuser/.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 9.2.1
>>> 20191008]
>>> Using /etc/ansible/ansible.cfg as config file
>>> host_list declined parsing /home/adminuser/Desktop/DM/inventory.yml as
>>> it did not pass its verify_file() method
>>> script declined parsing /home/adminuser/Desktop/DM/inventory.yml as it
>>> did not pass its verify_file() method
>>> Parsed /home/adminuser/Desktop/DM/inventory.yml inventory source with
>>> ini plugin
>>> META: ran handlers
>>> Using module file
>>> /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_ping.ps1
>>> Pipelining is enabled.
>>> [WARNING]: ansible_winrm_cert_validation unsupported by pywinrm (is an
>>> up-to-date version of pywinrm installed?)
>>> <10.1.85.246> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT
>>> 5985 TO 10.1.85.246
>>> Using module file
>>> /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_ping.ps1
>>> Pipelining is enabled.
>>> [WARNING]: ansible_winrm_cert_validation unsupported by pywinrm (is an
>>> up-to-date version of pywinrm installed?)
>>> <10.1.85.236> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT
>>> 5985 TO 10.1.85.236
>>> build-machine3 | UNREACHABLE! => {
>>> "changed": false,
>>> "msg": "ntlm: the specified credentials were rejected by the server",
>>> "unreachable": true
>>> }
>>> EXEC (via pipeline wrapper)
>>> build-machine2 | SUCCESS => {
>>> "changed": false,
>>> "invocation": {
>>> "module_args": {
>>> "data": "pong"
>>> }
>>> },
>>> "ping": "pong"
>>> }
>>> META: ran handlers
>>> META: ran handlers
>>>
>>> On build-machine2 everything is open, firewall disabled.
>>> But on build-machine3 this problem occured but ICMP all protocols
>>> enabled and winrm also.
>>>
>>> --
> 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/23d75dbc-5150-442c-a7d3-22b67aa09a22n%40googlegroups.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/CA%2BnV636eXWHf3P9jPNvE74JM2EAxnP--Fq9R8%2Bo3f%3DTbgtxv7A%40mail.gmail.com.


Re: [ansible-project] ansible tower - command works BUT playbook fails to connect to the host via ssh

2020-06-12 Thread Thanh Nguyen Duc
Try to run with sudo?

Sent from my iPhone

> On Jun 12, 2020, at 23:55, Stefan Hornburg (Racke)  wrote:
> 
> On 6/12/20 5:31 PM, Laci wrote:
>> In my ansible tower I can execute a command successfully on a remote server, 
>> however when I try to run a playbook I get:
>> 
>> {
>> "msg": "Failed to connect to the host via ssh: Warning: Permanently 
>> added 'hostname,10.1.4.66' (ECDSA) to the list
>> of known hosts.\r\nPermission denied 
>> (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive).",
>> "unreachable": true,
>> "changed": false
>> }
>> 
>> Seems to be a weird issue, did someone saw and solved this before?
> 
> This group is dedicated to Ansible itself, not Tower or AWX.
> 
> Please contact RedHat support.
> 
> 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/7ea6e452-bd00-408f-a1eb-36378bff57deo%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/b6428221-639a-5a9e-f0d2-506515df0792%40linuxia.de.

-- 
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/6558A5DB-373C-4747-A220-1D5A020CDB63%40gmail.com.


Re: [ansible-project] Need some data filter from meta data which came from custom module.

2020-04-16 Thread Thanh Nguyen Duc
Seem like you can register the result result and extract only the meta:
register: result
debug:
  var: result.meta

Anyway, you must see how is the data your module return:)
Sent from my iPhone

> On Apr 16, 2020, at 20:29, Venu Devannagari  wrote:
> 
> 
> I am getting following output from my ansible custom module '{'failed': 
> False, 'meta': {'Unused Policy Rules IDS': [0, 3, 4, 5, 6]}, 'changed': 
> False}' to one variable .I need to fetch only "{'Unused Policy Rules IDS': 
> [0, 3, 4, 5, 6]"}.Can anyone help to resolve this issue.
> -- 
> 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/689b3317-c371-49b8-b052-4a743fffe587%40googlegroups.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/E530E62C-1546-42B2-AE1C-5819F2A6039F%40gmail.com.


Re: [ansible-project] "Win_Command" module not working to connect localhost to run Powershell script from ansible which is installed in windows10

2020-04-16 Thread Thanh Nguyen Duc
Localhost is your ansible server and it doesn’t work with windown module, you 
need to specify the client group name

Sent from my iPhone

> On Apr 16, 2020, at 16:59, Pavan K Kumar  wrote:
> 
> 
> Hello Experts,
> 
> 
> 
> I'm new to Ansible and PowerShell.
> 
> 
> 
> I have installed cygwin in my windows 10 Operating system and installed 
> ansible and its related packages as per below mail.
> 
> https://geekflare.com/ansible-installation-windows/
> 
> 
> 
> Here are the environment details
> 
> Ansible version:  2.8.4
> python version : 3.7.7 (default, Apr 10 2020, 07:59:19) [GCC 9.3.0]
> 
> Powershell Version: 5.1.17763.1007
> 
> 
> 
> on above successful setup, i tried to run my below sample ansible script with 
> hosts as "localhost"
> 
> 
> 
> - hosts: localhost
> 
>   tasks:
> 
>   - name: "run whoami"
> 
> win_command: whoami
> 
> register: whoami_out
> 
>   - debug: var=whoami_out.stdout_lines
> 
> 
> but, i am ending up with the below error
> 
> [WARNING]: provided hosts list is empty, only localhost is available. Note 
> that the implicit localhost does not match 'all'
> 
> PLAY [localhost] 
> ***
> 
> TASK [Gathering Facts] 
> *
> ok: [localhost]
> 
> TASK [run whoami] 
> **
> fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": 
> "/home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768864612631/AnsiballZ_win_command.ps1
>  : The term 
> \r\n'/home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768864612631/AnsiballZ_win_command.ps1'
>  is not \r\nrecognized as the name of a cmdlet, function, script file, or 
> operable program. Check the spelling of the name, or if \r\na path was 
> included, verify that the path is correct and try again.\r\nAt line:1 
> char:1\r\n+ 
> /home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768 
> ...\r\n+ 
> ~\r\n + 
> CategoryInfo : ObjectNotFound: (/home/Pavan.Kam...win_command.ps1:String) [], 
> CommandNotFoundException\r\n + FullyQualifiedErrorId : 
> CommandNotFoundException\r\n \r\n", "module_stdout": "", "msg": "MODULE 
> FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
> 
> PLAY RECAP 
> *
> localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 
> ignored=0
> 
> 
> and i tried the 2nd approach by creating my windows 10 machine ip address in 
> etc/ansible/ansible.cfg and referred the same in asnible playbook as below
> 
> - hosts: all
>   tasks:
>   - name: "run whoami"
> win_command: whoami
> register: whoami_out
>   - debug: var=whoami_out.stdout_lines 
> 
> this time also ended up with the different error, PFB
> 
> PLAY [all] 
> *
> 
> TASK [Gathering Facts] 
> *
> fatal: [192.***.*.***]: UNREACHABLE! => {"changed": false, "msg": "Failed to 
> connect to the host via ssh: ssh: connect to host 192.***.*.*** port 22: 
> Connection refused", "unreachable": true}
> 
> PLAY RECAP 
> *
> 192.***.*.***   : ok=0changed=0unreachable=1failed=0
> skipped=0rescued=0ignore 
> 
> Kindly help me, is it something the environment set up issue. Im completely 
> clueless why it is not working as im new to this technology.
> 
> 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/0a657327-034b-4131-a9b7-9ee99364889a%40googlegroups.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 

Re: [ansible-project] Re: Error message - "module_stderr": "/bin/sh: 1: powershell: not found\n", when running a powershell through win_command

2020-04-16 Thread Thanh Nguyen Duc
Why localhost? Localhost mean you are running it in the ansible server, not win 
10 client

Sent from my iPhone

> On Apr 16, 2020, at 17:04, Pavan K Kumar  wrote:
> 
> 
> Hi Kiran,
> 
> Did you got any fix for this ?
> 
> im also facing the same issue.. 
> 
>> On Sunday, February 23, 2020 at 12:38:16 AM UTC+5:30, Karthik Kumar wrote:
>> Iam trying to run the below simple playbook in ansible in windows 10 through 
>> ubuntu installed.
>> 
>> But Iam getting error as  "module_stderr": "/bin/sh: 1: powershell: not 
>> found\n", "module_stdout": 
>> Please let me know how to resolve this issue.
>> 
>> - name: Run Powershell Scripts
>>   hosts: localhost
>>   tasks:
>> - name: Run powershell script
>>   win_command: pwsh.exe -ExecutionPolicy ByPass -File 
>> C:/temp/Firstpowershellscript.ps1
> 
> -- 
> 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/0956a7ca-030f-41c6-a1e3-2e5c27b1dc9f%40googlegroups.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/605834A7-5D96-48CD-890C-86912D51AD75%40gmail.com.


[ansible-project] Manage Windows Patching with Ansible

2020-04-12 Thread Thanh Nguyen Duc
Currently, i am setting up an Ansible Engine server to manage the Window 
Patching in my test environment, i tried with the attached playbook but 
somehow ansible not able to complete it and always stuck at: META: ran 
handlers

My playbook:

---
- name: Set location
  hosts: localhost
  connection: local
  tasks:
- name: create file
  file:
path: /home/test01/log/WindowsPatches_{{ansible_date_time.date}}.txt
state: touch 
- name: Get window update patches available in server
  hosts: wsus
  serial:
- 3
  tasks:
- set_fact: 
oufile=/home/test01/log/success_{{ansible_date_time.date}}.txt
- name: Verify the Secondary Logon
  win_service:
name: seclogon
  register: service_info

- name: Enabled secondary logon
  win_service:
name: seclogon
start_mode: manual
state: started
  when: service_info.start_mode == 'disabled'

- name: find the patches
  win_updates:
category_names:
- SecurityUpdates
- CriticalUpdates
- UpdateRollups
state: searched
log_path: C:\ansible_wu.txt
  register: update_result
  ignore_errors: yes

- name: Write data to file
  lineinfile:
dest: "{{outfile}}"
line: "{{inventory_hostname}} has 
{{update_result.found_update_count}} patches pending installation"
insertafter: EOF
  delegate_to: localhost

- name: Stop secondary logon
  win_service:
name: seclogon
start_mode: disabled
state: stopped
  when: service_info.start_mode == 'disabled'

===

[image: Stuck.JPG]

-- 
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/bdbcb57b-e3fe-47ff-a855-45a047e25879%40googlegroups.com.