[ansible-project] Ansible Dynamic Inventory for Azure

2019-02-23 Thread ameya agashe
Hi Guys,

I am trying to play around with Ansible dynamic inventory to get software
installed/perform configuration management.

I have executed instructions as given by Microsoft here:
https://docs.microsoft.com/en-us/azure/ansible/ansible-manage-azure-dynamic-inventories

Commands from my VM are here:

az group create --resource-group ansible-inventory-test-rg --location eastus
az vm create --resource-group ansible-inventory-test-rg  --name
ansible-inventory-test-vm1  --image UbuntuLTS
--generate-ssh-keys
az vm create --resource-group ansible-inventory-test-rg  --name
ansible-inventory-test-vm2  --image UbuntuLTS
--generate-ssh-keys
az account show
az resource tag --tags nginx --id /subscriptions//resourceGroups/ansible-inventory-test-rg/providers/Microsoft.Compute/virtualMachines/ansible-inventory-test-vm1
wget
https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/azure_rm.py
chmod +x azure_rm.py
ansible -i azure_rm.py ansible-inventory-test-rg -m ping

However, it errors out as below:

[WARNING]:  * Failed to parse
/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py with script
plugin: Inventory script
(/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py) had an
execution error: /usr/lib/python2.7/site-packages/requests/__init__.py:91:
RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn't
match a supported version!   RequestsDependencyWarning) 'Cloud' object has
no attribute 'find'

[WARNING]:  * Failed to parse
/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py with ini
plugin:
/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py:22: Error
parsing host definition ': No closing quotation

[WARNING]: Unable to parse
/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py as an
inventory source

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

[WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

[WARNING]: Could not match supplied host pattern, ignoring:
ansible-inventory-test-rg

I am unable to understand what is the missing link here as I have executed
as it is documented from Microsoft site, am I missing here anything?

Also how that Python script would know which subscription, which resource
group and which VM's it has to apply a particular playbook?

Kind Regards,
Ameya Agashe

-- 
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/CAG9tf--mmUNngJ%3D%3DEpieRZ_%3DWAEfwSKzAJsgZJq3cTXBnU0Dpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Failed Authentication

2019-02-23 Thread VeGeTa-X
also here is a copy are my settings of for ansible.cfg and version I am 
running

ansible 2.7.8

  config file = /etc/ansible/ansible.cfg

  configured module search path = ['/usr/share/ansible']

  ansible python module location = 
/usr/local/lib/python3.6/site-packages/ansible

  executable location = /usr/local/bin/ansible

  python version = 3.6.8 (default, Feb 22 2019, 12:24:32) [GCC 4.4.7 
20120313 (Red Hat 4.4.7-23)]

[root@ansiblevm ansible]#

 

 

 

 

cat ansible.cfg | grep -v "#"

 

 

[defaults]

 

 

library= /usr/share/ansible/

remote_tmp = $HOME/.ansible/tmp

forks  = 5

 

 

timeout = 10

 

 

log_path = /var/log/ansible.log

 

 

[inventory]

 

 

[privilege_escalation]

 

[paramiko_connection]

 

[ssh_connection]

 

 

[persistent_connection]

 

 

[accelerate]

 

[selinux]

 

[colors]

[diff]

On Friday, February 22, 2019 at 4:56:07 PM UTC-5, VeGeTa-X wrote:
>
> I am starting out at ansible with a basic playbook to learn ansible I am 
> getting the error message below I know the user and creds are correct I 
> have logged into that switch from
> ansible server can someone please let me know what I am missing?
>
>
>
> #error message
>
> TASK [Gathering Facts] 
> 
>
> fatal: [vegeta01_temp]: UNREACHABLE! => {"changed": false, "msg": "Failed 
> to connect to the host via ssh: 
> \nPermission
>  
> denied (publickey,password,keyboard-interactive).", "unreachable": true}
>
>
> ---
>
>  
>
> - name: nxos_facts module
>
>   hosts: vegeta_core
>
>   vars:
>
> ssh:
>
>   host: “{{ansible_host}”
>
>   username: “{{vegeta}”
>
>   password: “{{abc123}”
>
>  
>
> nxapi:
>
>   host: "{{ ansible_host }}"
>
>   username: "{{ vegeta }}”
>
>   password: "{{ abc123 }}"
>
>   transport: nxapi
>
>   use_ssl: no
>
>   validate_certs: no
>
>   port: 80 
>
>  
>
>  
>
>   tasks:
>
> - name: nxos_facts ssh
>
>   nxos_facts:
>
> provider: "{{ssh}}"
>
>  
>
> - name: nxos_facts nxapi
>
>   nxos_facts:
>
> provider: "{{ nxapi }}"   
>

-- 
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/3db08eee-6d50-4c9d-8d9a-2fcd3b21f09c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible Failed Authentication

2019-02-23 Thread VeGeTa-X
ok fixed the username and password and I am still not able to login using 
the playbook

Also to answer your question yes I am able to login using vegeta with just 
plain ssh into switch 


On Saturday, February 23, 2019 at 8:58:52 AM UTC-5, Wawrzek Niewodniczanski 
wrote:
>
> On Fri, 22 Feb 2019 at 21:56, VeGeTa-X > 
> wrote: 
> > 
> [...] 
> > please let me know what I am missing? 
>
> There might be something else, but these 3 lines look wrong, just one 
> "}" should be two. 
> > ssh: 
> >   host: “{{ansible_host}” 
> >   username: “{{vegeta}” 
> >   password: “{{abc123}” 
>
> Also can you ssh to that server with the username you define as 
> variable "{{ vegeta }}". 
>
> Wawrzek 
>
>
>
> -- 
> Dr  Wawrzyniec Niewodniczańskior Wawrzek for short 
>   PhD in Quantum Chemistry  & MSc in Molecular Engineering 
>WWW: http://wawrzek.name E-MAIL: jo...@wawrzek.name  
>   Linux User #177124 
>

-- 
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/7326e51a-9390-4e1d-b6ac-90d01879d309%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Using include_tasks with the same file several times inside a role

2019-02-23 Thread Kai Stian Olstad
On 23.02.2019 23:07, Paulo Silva wrote:
> It was a typo, even like that only the first one is executed.

You have only shown us part of your code, since it's not working you have 
error(s) in that code.


-- 
Kai Stian Olstad

-- 
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/f0abeee7-2e62-9b66-0cdf-503a6c36a4f9%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Using include_tasks with the same file several times inside a role

2019-02-23 Thread Paulo Silva
It was a typo, even like that only the first one is executed.

Regards

A sábado, 23/02/2019, 15:22, BHARATHI DURAI RAJ 
escreveu:

> Try this one
>
> - name: task with var1
>   include_tasks: external.yaml
>   vars:
> my_var: var1
>
> - name: task with var2
>   include_tasks: external.yaml
>   vars:
> my_var: var2
>
> On Saturday, 23 February 2019 20:27:12 UTC+5:30, Paulo Silva wrote:
>>
>> Hi,
>>
>> Is it possible do to something like this inside a role?
>>
>> - name: task with var1
>>   include_tasks: external.yaml
>>   vars:
>> my_var=var1
>>
>> - name task with var2
>>   include_tasks: external.yaml
>>   vars:
>> my_var=var2
>>
>> I'm no getting any error but it appears that only the first include_tasks
>> is used, switching to import_tasks as the same behavior.
>>
>> Is is expected? Any other to achieve this?
>>
>> 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 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/dd2b9c97-e819-4b7c-8388-5f4a01cf9d2c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHJdQrk9K8GpH80uwUL8KLnO6GEqHcrVNB1K_BN8yOg4QpWjNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: How can i handle ADFS in between Ansible and ServiceNow Portal to Create, Update Snow tickets?

2019-02-23 Thread Nuno
Dear Ankit,

Were you able to solve the problem? I am currently in a similar situation 
and I am still struggling to solve it.

Thanks!

sábado, 24 de Novembro de 2018 às 10:32:36 UTC, Ankit Vashistha escreveu:
>
> I was trying to using snow modules (
> https://docs.ansible.com/ansible/2.7/modules/snow_record_module.html). 
> This works for a normal snow instance where there is no ADFS in between. 
> However, in our organization, we have ADFS which cannot be avoided because 
> of which the *snow_record* module fails to work.
>
> Is there a way i could handle this somwhow? Any example would be greatly 
> appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/6584acd6-ff0e-4b20-9bd5-3daabb4afbc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible, CyberArk, root and SSH

2019-02-23 Thread imanuel . greenfeld1
Hello

We have Ansible in our organisation which deploys software across our 
Development servers.

 

IT Security recently CyberArk'd each of the Development servers and now 
Ansible cannot log into each of the machines (not even as 'root').

 

When I try manually to SSH as 'root' with the password from CyberArk 
(copied and pasted) I'm still unable to log on.  The only way to open a 
session as ‘root’ is from within CyberArk.

 

I read about AIM agents but my understanding is that all that this will do 
is retrieve the password from CyberArk and pass it back to Ansible.  

 

In other words, how will this help me for as long as the servers are 
Unreachable and I cannot even SSH from one machine to another not even as 
'root' ?

 

Am I going about this the right way or is it possible that additional 
security been added (such as firewalls) which I am unaware of ? 

 

Can you help ?

 

Many thanks for your advice.

-- 
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/eaeaac14-2c21-4e7b-9d92-6d93a1c65c8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Use a variable from another host's variables

2019-02-23 Thread Kai Stian Olstad
On 23.02.2019 18:53, adsquai...@gmail.com wrote:
> Hello all,
> 
> I have an inventory file populated with two hosts and I would like to use
> the value of host B's variable on host A. I had no luck with using hostvars
> in the template.
> 
> Example inventory file. Note this will be a dynamically generated file.
> 
> [host_a]
> x.x.x.x
> [host_a:vars]
> eth0=192.168.1.1
> eth1=192.168.2.1
> 
> 
> [host_b]
> x.x.x.x
> [host_b:vars]
> eth0=192.168.1.2
> eth1=192.168.2.2
> 
> I want to use 192.168.2.1 from host_a's variable in a template that will
> generate a config file on both host a and b. For example, the config on
> both hosts will have an entry like this: clustered_ips = 192.168.2.1,
> 192.168.2.2
> 
> I tried this in the template file but get undefined variable.
> 
> {{ hostvars[host_a][eth0] }}

Without quotes inside [] they are taken as variables, so host_a and eth0 is 
taken as variables.
So you're looking for this

  {{ hostvars['host_a']['eth0'] }}

-- 
Kai Stian Olstad

-- 
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/18e47086-e90e-6f41-b852-23c00cb3a5db%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Use a variable from another host's variables

2019-02-23 Thread adsquaired
Hello all,

I have an inventory file populated with two hosts and I would like to use 
the value of host B's variable on host A. I had no luck with using hostvars 
in the template.

Example inventory file. Note this will be a dynamically generated file. 

[host_a]
x.x.x.x
[host_a:vars]
eth0=192.168.1.1
eth1=192.168.2.1


[host_b]
x.x.x.x
[host_b:vars]
eth0=192.168.1.2
eth1=192.168.2.2

I want to use 192.168.2.1 from host_a's variable in a template that will 
generate a config file on both host a and b. For example, the config on 
both hosts will have an entry like this: clustered_ips = 192.168.2.1, 
192.168.2.2

I tried this in the template file but get undefined variable.

{{ hostvars[host_a][eth0] }}


How can I accomplish this?

Thanks in advance.

Steven

-- 
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/59ff9ef7-8b96-46a9-ba60-cd518717183a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using include_tasks with the same file several times inside a role

2019-02-23 Thread BHARATHI DURAI RAJ
Try this one

- name: task with var1
  include_tasks: external.yaml
  vars:
my_var: var1

- name: task with var2
  include_tasks: external.yaml
  vars:
my_var: var2

On Saturday, 23 February 2019 20:27:12 UTC+5:30, Paulo Silva wrote:
>
> Hi,
>
> Is it possible do to something like this inside a role?
>
> - name: task with var1
>   include_tasks: external.yaml
>   vars:
> my_var=var1
>
> - name task with var2
>   include_tasks: external.yaml
>   vars:
> my_var=var2
>
> I'm no getting any error but it appears that only the first include_tasks 
> is used, switching to import_tasks as the same behavior.
>
> Is is expected? Any other to achieve this?
>
> 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 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/dd2b9c97-e819-4b7c-8388-5f4a01cf9d2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using include_tasks with the same file several times inside a role

2019-02-23 Thread Paulo Silva
Hi,

Is it possible do to something like this inside a role?

- name: task with var1
  include_tasks: external.yaml
  vars:
my_var=var1

- name task with var2
  include_tasks: external.yaml
  vars:
my_var=var2

I'm no getting any error but it appears that only the first include_tasks 
is used, switching to import_tasks as the same behavior.

Is is expected? Any other to achieve this?

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 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/e77ce207-6584-45f5-a578-9efbc5154354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible Playbook

2019-02-23 Thread BHARATHI DURAI RAJ
Can you please help me on correcting the below playbook...
- name: Delete  Project

uri:

  url: "https://dev.azure.com/{{ org }}/_apis/projects?api-version=4.1"

  method: DELETE

  user: "{{ vsts_user }}"

  password: "{{ pattoken }}"

  return_content: yes

  force_basic_auth: yes

  validate_certs: yes

  body_format: json

  headers:

Accept: "application/json"

  body: "{{ lookup('template','./templates/{{ Testing_bharathidurairaj 
}}') }}"

  status_code: 202

when: list_project.status != 200

register: vsts_project

delegate_to: localhost

run_once: true

I am trying to delete a azure devops project using the above playbook

-- 
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/8c36d916-a7d6-4cb7-9957-95b2644dc97d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Dealing with non-fixed length lists of variables

2019-02-23 Thread Spencer Webb
Hi all,

I've got a playbook that uses variables to create a load balanced pool and 
the required members on our test F5 BigIP.

I've got the basics working without issue, however, the number of members 
of a pool for any given run is not a fixed number and could range from 1 up 
to say 10.

I'm running Ansible Tower and invoking the template via tower-cli. I'm 
using extra-vars to provide realip and realserver and looped through. The 
default values are set to null so I was hoping to loop through the list 
until a null value for item.host is observed. I'm not sure if this is the 
best way to deal with this, it's the first time that I've tried to deal 
with variable lists that are not fixed in number.

Here's my current code, any help would be greatly appreciated.

Cheers
Spence

---

- name: Create a VIP, pool and pool members
 hosts: all
 connection: local

  vars:
   provider:
 password: Password
 server: IP
 user: username
 validate_certs: no
 server_port: port

  tasks:
   - name: Create a pool
 bigip_pool:
   provider: "{{ provider }}"
   lb_method: ratio-member
   name: "{{ service }}"
   slow_ramp_time: 120
 delegate_to: localhost

- name: Add members to pool
 bigip_pool_member:
   provider: "{{ provider }}"
   description: "webserver {{ item.name }}"
   host: "{{ item.host }}"
   name: "{{ item.name }}"
   pool: "{{ service }}"
   port: "{{ lbport }}"
 loop:
   - { host: "{{ realip1 }}",  name: "{{ realserver1 }}" }
   - { host: "{{ realip2 }}",  name: "{{ realserver2 }}" }
   - { host: "{{ realip3 }}",  name: "{{ realserver3 }}" }
   - { host: "{{ realip4 }}",  name: "{{ realserver4 }}" }
   - { host: "{{ realip5 }}",  name: "{{ realserver5 }}" }
   - { host: "{{ realip6 }}",  name: "{{ realserver6 }}" }
   - { host: "{{ realip7 }}",  name: "{{ realserver7 }}" }
   - { host: "{{ realip8 }}",  name: "{{ realserver8 }}" }
   - when: item.host != ""
   - 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 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/cf8e3969-eeaf-422b-9fbd-4ca36d19d660%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible Failed Authentication

2019-02-23 Thread Wawrzek Niewodniczanski
On Fri, 22 Feb 2019 at 21:56, VeGeTa-X  wrote:
>
[...]
> please let me know what I am missing?

There might be something else, but these 3 lines look wrong, just one
"}" should be two.
> ssh:
>   host: “{{ansible_host}”
>   username: “{{vegeta}”
>   password: “{{abc123}”

Also can you ssh to that server with the username you define as
variable "{{ vegeta }}".

Wawrzek



-- 
Dr  Wawrzyniec Niewodniczańskior Wawrzek for short
  PhD in Quantum Chemistry  & MSc in Molecular Engineering
   WWW: http://wawrzek.name E-MAIL: j...@wawrzek.name
  Linux User #177124

-- 
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/CAC7-vpAYy%3DVbaJzEO6r0uTqO2q-%2BRoc_v%2ByOf_di%3Dru9HK2scA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.