[ansible-project] Re: Issue with dynamic inventory for azure

2023-01-18 Thread abhay srivastava
On Wed, 18 Jan 2023 at 14:11, abhay srivastava 
wrote:

>
> Hello all,
>
> We are facing one issue with dynamic inventory of azure.
>
> Getting below error
>
> ansible-inventory -i test.azure_rm.yaml --graph -vvv
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *ansible-inventory [core 2.13.7]config file =
> /etc/ansible/ansible.cfgconfigured module search path =
> ['/root/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']ansible python module location =
> /usr/lib/python3/dist-packages/ansibleansible collection location =
> /root/.ansible/collections:/usr/share/ansible/collectionsexecutable
> location = /usr/bin/ansible-inventorypython version = 3.10.6 (main, Nov 14
> 2022, 16:10:14) [GCC 11.3.0]jinja version = 3.0.3libyaml = TrueUsing
> /etc/ansible/ansible.cfg as config filehost_list declined parsing
> /root/test.azure_rm.yaml as it did not pass its verify_file() methodscript
> declined parsing /root/test.azure_rm.yaml as it did not pass its
> verify_file() methodUsing inventory plugin
> 'ansible_collections.azure.azcollection.plugins.inventory.azure_rm' to
> process inventory source '/root/test.azure_rm.yaml'toml declined parsing
> /root/test.azure_rm.yaml as it did not pass its verify_file()
> method[WARNING]: * Failed to parse /root/test.azure_rm.yaml with auto
> plugin: Failed to get credentials. Either pass asparameters, set
> environment variables, define a profile in ~/.azure/credentials, or install
> Azure CLI and log in (az login).File
> "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
> parse_sourceplugin.parse(self._inventory, self._loader, source,
> cache=cache)File
> "/usr/lib/python3/dist-packages/ansible/plugins/inventory/auto.py", line
> 59, in parseplugin.parse(inventory, loader, path, cache=cache)File
> "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py",
> line 220, in parseself._credential_setup()File
> "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py",
> line 241, in _credential_setupself.azure_auth =
> AzureRMAuth(**auth_options)File
> "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
> line 1479, in initself.fail("Failed to get credentials. Either pass as
> parameters, set environment variables, "File
> "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
> line 1605, in failself._fail_impl(msg)File
> "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
> line 1608, in _default_fail_implraise AzureRMAuthException(msg)[WARNING]: *
> Failed to parse /root/test.azure_rm.yaml with yaml plugin: Plugin
> configuration YAML file, not YAML inventoryFile
> "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
> parse_sourceplugin.parse(self._inventory, self._loader, source,
> cache=cache)File
> "/usr/lib/python3/dist-packages/ansible/plugins/inventory/yaml.py", line
> 114, in parseraise AnsibleParserError('Plugin configuration YAML file, not
> YAML inventory')[WARNING]: * Failed to parse /root/test.azure_rm.yaml with
> ini plugin: Invalid host pattern 'plugin:' supplied, ending in':' is not
> allowed, this character is reserved to provide a port.File
> "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
> parse_sourceplugin.parse(self._inventory, self._loader, source,
> cache=cache)File
> "/usr/lib/python3/dist-packages/ansible/plugins/inventory/ini.py", line
> 136, in parseraise AnsibleParserError(e)[WARNING]: Unable to parse
> /root/test.azure_rm.yaml as an inventory source[WARNING]: No inventory was
> parsed, only implicit localhost is available@all:|--@ungrouped:*
>
> Able to do az vm list
> az vm list | wc -l
> 1341
> my azure inventory is below
> cat test.azure_rm.yaml
> plugin: azure.azcollection.azure_rm
> auth_source: auto
> include_vm_resource_groups:
> - '*'
> vars:
> ansible_python_interpreter: /usr/bin/python3
>
>
> --
> Regards,
> Abhay Srivastava
> ---
> Mob-9160512000
>


-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

-- 
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/CAPKgz8Ur02aSos3A1v%2Bsg%2B2fHzaUWepPDXvFyqgmxXyCmTTzHg%40mail.gmail.com.


[ansible-project] Issue with dynamic inventory for azure

2023-01-18 Thread abhay srivastava
Hello all,

We are facing one issue with dynamic inventory of azure.

Getting below error

ansible-inventory -i test.azure_rm.yaml --graph -vvv













































*ansible-inventory [core 2.13.7]config file =
/etc/ansible/ansible.cfgconfigured module search path =
['/root/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules']ansible python module location =
/usr/lib/python3/dist-packages/ansibleansible collection location =
/root/.ansible/collections:/usr/share/ansible/collectionsexecutable
location = /usr/bin/ansible-inventorypython version = 3.10.6 (main, Nov 14
2022, 16:10:14) [GCC 11.3.0]jinja version = 3.0.3libyaml = TrueUsing
/etc/ansible/ansible.cfg as config filehost_list declined parsing
/root/test.azure_rm.yaml as it did not pass its verify_file() methodscript
declined parsing /root/test.azure_rm.yaml as it did not pass its
verify_file() methodUsing inventory plugin
'ansible_collections.azure.azcollection.plugins.inventory.azure_rm' to
process inventory source '/root/test.azure_rm.yaml'toml declined parsing
/root/test.azure_rm.yaml as it did not pass its verify_file()
method[WARNING]: * Failed to parse /root/test.azure_rm.yaml with auto
plugin: Failed to get credentials. Either pass asparameters, set
environment variables, define a profile in ~/.azure/credentials, or install
Azure CLI and log in (az login).File
"/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
parse_sourceplugin.parse(self._inventory, self._loader, source,
cache=cache)File
"/usr/lib/python3/dist-packages/ansible/plugins/inventory/auto.py", line
59, in parseplugin.parse(inventory, loader, path, cache=cache)File
"/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py",
line 220, in parseself._credential_setup()File
"/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py",
line 241, in _credential_setupself.azure_auth =
AzureRMAuth(**auth_options)File
"/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
line 1479, in initself.fail("Failed to get credentials. Either pass as
parameters, set environment variables, "File
"/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
line 1605, in failself._fail_impl(msg)File
"/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
line 1608, in _default_fail_implraise AzureRMAuthException(msg)[WARNING]: *
Failed to parse /root/test.azure_rm.yaml with yaml plugin: Plugin
configuration YAML file, not YAML inventoryFile
"/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
parse_sourceplugin.parse(self._inventory, self._loader, source,
cache=cache)File
"/usr/lib/python3/dist-packages/ansible/plugins/inventory/yaml.py", line
114, in parseraise AnsibleParserError('Plugin configuration YAML file, not
YAML inventory')[WARNING]: * Failed to parse /root/test.azure_rm.yaml with
ini plugin: Invalid host pattern 'plugin:' supplied, ending in':' is not
allowed, this character is reserved to provide a port.File
"/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 290, in
parse_sourceplugin.parse(self._inventory, self._loader, source,
cache=cache)File
"/usr/lib/python3/dist-packages/ansible/plugins/inventory/ini.py", line
136, in parseraise AnsibleParserError(e)[WARNING]: Unable to parse
/root/test.azure_rm.yaml as an inventory source[WARNING]: No inventory was
parsed, only implicit localhost is available@all:|--@ungrouped:*

Able to do az vm list
az vm list | wc -l
1341
my azure inventory is below
cat test.azure_rm.yaml
plugin: azure.azcollection.azure_rm
auth_source: auto
include_vm_resource_groups:
- '*'
vars:
ansible_python_interpreter: /usr/bin/python3


-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

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


[ansible-project] Dynamic inventory on openstack

2021-04-21 Thread abhay srivastava
Hello team,

How to run ansible using openstack.py inventory script.

I need to run ansible playbook on ecs based on tag. So how to use it.


-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

-- 
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/CAPKgz8XEAXkCk5jgmLPagsOYf8q1%3Dix-TONfwTCsZFuV6WTUTA%40mail.gmail.com.


Re: [ansible-project] ERROR! 'win_package' is not a valid attribute for a Play (Ansible controller version is 2.9)

2020-05-04 Thread abhay srivastava
Please installed pywin module in Ansible server.

On Mon, 4 May 2020 at 20:44, Amit Kumar  wrote:

> Hi ,
>
> As i have created two simple playbook to remove file from window system
> and create the file on window system.
> But getting error while i execute the both playbook. (Ansible controller
> version is 2.9)
>
> 1. remove_file.yml
> ---
>  - name: remove a file (check mode)
>hosts: win
>win_package:
> path: C:\ansible_wu.txt
> state: absent
> register: remove_file_check
> check_mode: yes
> ***
> Error-
> ***
> ERROR! 'win_package' is not a valid attribute for a Play
>
> The error appears to be in '/home/ansible/rx_testing/win_remove_file.yml':
> line 2, column 4, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
> ---
>  - name: remove a file (check mode)
>^ here
> ++
> 2. touch.yml
> ---
>  - hosts: win
>name: Create the file
>win_file:
> path: C:\amit.txt
> state: touch
> _
> Error
> --
> ERROR! 'win_file' is not a valid attribute for a Play
>
> The error appears to be in '/home/ansible/rx_testing/win_touch.yml': line
> 2, column 4, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
> ---
>  - hosts: win
>^ here
> *
>
> Regards
> Amit
>
> --
> 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/41963f29-5fd4-4d6e-b2db-f063ae6361e7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/41963f29-5fd4-4d6e-b2db-f063ae6361e7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

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


Re: [ansible-project] Variable value saving into one column of csv file

2019-10-16 Thread abhay srivastava
Can you please provide me any example.

On Wed 16 Oct, 2019, 4:38 PM Stefan Hornburg (Racke), 
wrote:

> On 10/16/19 11:27 AM, abhay srivastava wrote:
> >
> > Hi,
> >
> > I want to save 1st variable value coming from loop into 1st column  and
> 2nd variable value coming from loop into 2nd
> > column and so on.
> >
> > - local_action: lineinfile line="{{
> result.results[item|int].container.Config.Hostname }}" dest=/tmp/abhay.csv
> >   with_sequence: start=0 end="{{ count|int }}"
> >
> > - local_action: lineinfile line="{{
> result.results[item|int].container.State.Status }}" dest=/tmp/abhay.csv
> >   with_sequence: start=0 end="{{ count|int }}"
> >
> > Result should be like below
> >
> > var1.value1 var2.value1
> > var1.value2  var2.value2
> > var1.value3  var2.value3
> >
> >
> >  How to achieve this.
> >
>
> I would suggest to use a template instead of lineinfile.
>
> 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/c64c7e1e-fd4e-4ee3-9884-4c39d96acb26%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/c64c7e1e-fd4e-4ee3-9884-4c39d96acb26%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5d9abc65-b342-a980-5e14-1ca30568e73d%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/CAPKgz8W_PezEBEj__x9_mA%2BxsRTyuLmpMiU27MypMtTX%3DwfX_w%40mail.gmail.com.


[ansible-project] Variable value saving into one column of csv file

2019-10-16 Thread abhay srivastava

Hi,

I want to save 1st variable value coming from loop into 1st column  and 2nd 
variable value coming from loop into 2nd column and so on.

- local_action: lineinfile line="{{ 
result.results[item|int].container.Config.Hostname }}" dest=/tmp/abhay.csv 
  with_sequence: start=0 end="{{ count|int }}" 

- local_action: lineinfile line="{{ 
result.results[item|int].container.State.Status }}" dest=/tmp/abhay.csv 
  with_sequence: start=0 end="{{ count|int }}"

Result should be like below

var1.value1 var2.value1
var1.value2  var2.value2
var1.value3  var2.value3


 How to achieve this.


-- 
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/c64c7e1e-fd4e-4ee3-9884-4c39d96acb26%40googlegroups.com.


Re: [ansible-project] unable to copy ansible vriable into file

2019-10-15 Thread abhay srivastava
Thanks its work.

On Tuesday, 15 October 2019 14:50:30 UTC+5:30, Karl Auer wrote:
>
> The error is telling you exactly what the problem is. You need to work out 
> what might be causing that problem.
>
> In this case, a list object does not have an attribute called (in Unicode) 
> '0'.
>
> Your loop uses values from a sequence, and the first in the sequence is 
> '0'. This is used to dereference the variable result.results (as in, 
> result.results[item]...).
>
> I'm guessing that result.results is an empty list, OR maybe you should 
> cast item to be an integer:
>
> {{ result.results[item |int].container.Config.Hostname }}
>
> One option would be to output result in a debug statement before you try 
> to use it, so you can look at its structure and then dereference it 
> properly.
>
> BTW this is guesswork. I haven't read any doco or tested any of the above.
>
> Regards, K.
>
> On Tue, Oct 15, 2019 at 7:19 PM abhay srivastava  > wrote:
>
>>
>>
>> Error:
>>
>> TASK [lineinfile] 
>> ***
>> fatal: [192.168.1.158]: FAILED! => {"msg": "The task includes an option 
>> with an undefined variable. The error was: 'list object' has no attribute 
>> u'0'\n\nThe error appears to be in 
>> '/home/cloud/nidhi/ccepbook/nidhi-playbook.yml': line 31, column 5, but 
>> may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
>> offending line appears to be:\n\n\n  - local_action: lineinfile line=\"{{ 
>> result.results[item].container.Config.Hostname }}\" 
>> dest=/tmp/abhay.csv\n^ here\nWe could be wrong, but this one looks like 
>> it might be an issue with\nmissing quotes. Always quote template expression 
>> brackets when they\nstart a value. For instance:\n\nwith_items:\n  
>> - {{ foo }}\n\nShould be written as:\n\nwith_items:\n  - \"{{ foo 
>> }}\"\n"}
>>
>>
>>   - local_action: lineinfile line="{{ 
>> result.results[item].container.Config.Hostname }}" dest=/tmp/abhay.csv
>> with_sequence: start=0 end="{{ count|int }}"
>>
>>
>> here count is from 0 to 2
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2f0e435f-64c5-4550-8ad6-f56731c2007c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/2f0e435f-64c5-4550-8ad6-f56731c2007c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
>
> *Karl Auer* { manager, systems support }
> P: 1300 759 975
> E: ka...@2pisoftware.com 
> 2pisoftware.com
>
> GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
> Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>

-- 
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/5d9fd20b-7f12-41a7-bd36-0a1f2fecc3ce%40googlegroups.com.


[ansible-project] unable to copy ansible vriable into file

2019-10-15 Thread abhay srivastava


Error:

TASK [lineinfile] 
***
fatal: [192.168.1.158]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 'list object' has no attribute 
u'0'\n\nThe error appears to be in 
'/home/cloud/nidhi/ccepbook/nidhi-playbook.yml': line 31, column 5, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n  - local_action: lineinfile line=\"{{ 
result.results[item].container.Config.Hostname }}\" 
dest=/tmp/abhay.csv\n^ here\nWe could be wrong, but this one looks like 
it might be an issue with\nmissing quotes. Always quote template expression 
brackets when they\nstart a value. For instance:\n\nwith_items:\n  
- {{ foo }}\n\nShould be written as:\n\nwith_items:\n  - \"{{ foo 
}}\"\n"}


  - local_action: lineinfile line="{{ 
result.results[item].container.Config.Hostname }}" dest=/tmp/abhay.csv
with_sequence: start=0 end="{{ count|int }}"


here count is from 0 to 2

-- 
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/2f0e435f-64c5-4550-8ad6-f56731c2007c%40googlegroups.com.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-22 Thread abhay srivastava
Are you able to do sudo without password

On Tue 22 May, 2018, 10:05 PM 'Kallu Srikanth' via Ansible Project, <
ansible-project@googlegroups.com> wrote:

>
> Hi Abhay i still have the error
>
> Code : -
> ---
> - hosts: dpie_prod
>   user: dpiesa
>   become: true
>   become_method: enable
>   tasks:
>   - name: install telnet
> yum: pkg=telnet state=present update_cache=true
>
> ERROR:
>
> fatal: [lind01]: FAILED! => {"changed": false, "module_stderr": "Shared
> connection to lind01.\r\n", "module_stdout": "sudo: illegal option
> `-n'\r\nusage: sudo -h | -K | -k | -L | -l | -V | -v\r\nusage: sudo
> [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]\r\n{-i | -s
> | }\r\nusage: sudo -e [-S] [-p prompt] [-u username|#uid] file
> ...\r\n", "msg": "MODULE FAILURE", "rc": 1}
>
> But I can run this successfully manually on a server like this without
> password
> #dpiesa@lind01:/home/dpiesa> sudo yum install telnet
>
> Also can become root like this
>
> dpiesa@lind01:/home/dpiesa> become
> root@lind01:/root>
> On Monday, May 21, 2018 at 10:59:42 PM UTC-5, abhay srivastava wrote:
>>
>> Try:
>>
>> - hosts: dpie_prod
>>   user: dpiesa
>>   become:  True
>>   tasks:
>>   - name: install telnet
>> yum: pkg=telnet state=installed update_cache=true
>> #command: sudo yum install telnet -y
>>
>>
>>
>>
>> On Sat, May 19, 2018 at 12:56 AM, 'Kallu Srikanth' via Ansible Project <
>> ansible...@googlegroups.com> wrote:
>>
>>> Hi,
>>>
>>> I highly appreciate if anybody can help, please
>>>
>>> ###  playbook  ##
>>>
>>> - hosts: dpie_prod
>>>   user: dpiesa
>>>   tasks:
>>>   - name: install telnet
>>> yum: pkg=telnet state=installed update_cache=true
>>> #command: sudo yum install telnet -y
>>> become: yes
>>> become_user: root
>>> become_method: sudo
>>>
>>> The above does not work and throws this error
>>>
>>> TASK [install telnet]
>>> 
>>>  [WARNING]: Module invocation had junk after the JSON data: usage: sudo
>>> -e [-S] [-p prompt] [-u username|#uid] file ...
>>>
>>> fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false,
>>> "module_stderr": "Shared connection to lind01.corp.acxiom.net
>>> closed.\r\n", "module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h
>>> | -K | -k | -L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u
>>> username|#uid] [VAR=value]\r\n{-i | -s | }\r\nusage:
>>> sudo -e [-S] [-p prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE
>>> FAILURE", "rc": 1}
>>> to retry, use: --limit
>>> @/home/dpiesa/playbooks/install_telnet.retry
>>>
>>>
>>> ##
>>>
>>> But below works
>>>
>>> - hosts: dpie_prod
>>>   user: dpiesa
>>>   tasks:
>>>   - name: install telnet
>>> command: sudo yum install telnet -y
>>>
>>>
>>> 
>>>
>>> [dpiesa@cwypatch06 playbooks]$ ansible --version
>>> ansible 2.5.2
>>>   config file = /etc/ansible/ansible.cfg
>>>   configured module search path =
>>> [u'/home/dpiesa/.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  4 2017, 00:39:18) [GCC 4.8.5
>>> 20150623 (Red Hat 4.8.5-16)]
>>>
>>>
>>> I think I am not using become options correctly can somebody help ??
>>>
>>> Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project&quo

Re: [ansible-project] How to replace a word or a content in a file using ansible.

2018-05-22 Thread abhay srivastava
Use replace module.

https://docs.ansible.com/ansible/2.3/replace_module.html

On Tue, May 22, 2018 at 3:57 PM, Gowtham Nakulan 
wrote:

> I am trying to replace a word in file using Ansible.
>
> Any inputs how to acheive 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/c9ab4349-f5a5-4ffa-99fb-25c123466af7%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/c9ab4349-f5a5-4ffa-99fb-25c123466af7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKgz8VqztgAc6OtVF8mrDYQTgwUHhrOUt03jgY2wR0zxHBdSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-21 Thread abhay srivastava
Try:

- hosts: dpie_prod
  user: dpiesa
  become:  True
  tasks:
  - name: install telnet
yum: pkg=telnet state=installed update_cache=true
#command: sudo yum install telnet -y




On Sat, May 19, 2018 at 12:56 AM, 'Kallu Srikanth' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi,
>
> I highly appreciate if anybody can help, please
>
> ###  playbook  ##
>
> - hosts: dpie_prod
>   user: dpiesa
>   tasks:
>   - name: install telnet
> yum: pkg=telnet state=installed update_cache=true
> #command: sudo yum install telnet -y
> become: yes
> become_user: root
> become_method: sudo
>
> The above does not work and throws this error
>
> TASK [install telnet] **
> 
> **
>  [WARNING]: Module invocation had junk after the JSON data: usage: sudo -e
> [-S] [-p prompt] [-u username|#uid] file ...
>
> fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false,
> "module_stderr": "Shared connection to lind01.corp.acxiom.net
> closed.\r\n", "module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h
> | -K | -k | -L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u
> username|#uid] [VAR=value]\r\n{-i | -s | }\r\nusage:
> sudo -e [-S] [-p prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE
> FAILURE", "rc": 1}
> to retry, use: --limit @/home/dpiesa/playbooks/
> install_telnet.retry
>
> 
> 
> ##
>
> But below works
>
> - hosts: dpie_prod
>   user: dpiesa
>   tasks:
>   - name: install telnet
> command: sudo yum install telnet -y
>
> 
> 
> 
>
> [dpiesa@cwypatch06 playbooks]$ ansible --version
> ansible 2.5.2
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/home/dpiesa/.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  4 2017, 00:39:18) [GCC 4.8.5
> 20150623 (Red Hat 4.8.5-16)]
>
>
> I think I am not using become options correctly can somebody help ??
>
> Thank you.
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKgz8WjUHardGxCm5inSdxQRMh6Yw6cBc_GWEVWhp%3DrfGnUkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Trying to connect with another user if previews user unable to connect in playbook

2018-05-18 Thread abhay srivastava

   
   - 
   
   name: PLAY 1
   hosts: all
   gather_facts: false
   remote_user: centos
   tasks:
   - import_tasks: centos_change_user.yml
  ignore_errors: yes
   - 
   
   name: PLAY 2
   hosts: all
   gather_facts: false
   remote_user: cloud
   any_errors_fatal: true
   
   tasks:
   - import_tasks: cloud_change_user.yml
  ignore_errors: yes
   
But this palybook giving error as host is unreachable for cloud user. but 
this should run for atleast centos user.

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a63b51fb-a812-4175-8aee-ee8d12e8e153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.