Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Bikram
Thanks a lot Vladimir. I really appreciate your help.

With the following combination it works:
ansible_host and connection=ansible.netcommon.network_cli

Previous setting was:
ansible_host and connection=local [which actually
worked on ansible version 2.9.11 but my current version is 2.13.7]

-Bikram

On Thu, Jun 1, 2023 at 7:01 PM Vladimir Botka  wrote:

> Try to isolate your problem:
>
> * Create the inventory
>
> shell> cat hosts
> [test]
> NEXUS3172P
>
> [test:vars]
> ansible_host=10.131.88.10
> ansible_network_os=nxos
> username=
> password=x
>
> * Create a simple playbook
>
> shell> cat pb.yml
> - hosts: NEXUS3172P
>   gather_facts: false
>   tasks:
> - nxos_facts:
> gather_subset: hardware
>
> * Debug the connection (-)
>
> shell> ansible-playbook -i hosts - pb.yml
>
>
> --
> 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/CAEFfMJT1km6wzyTyWW31EL5EBLCJ4GRXG1P1xw4i1pVJWTPznw%40mail.gmail.com.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Vladimir Botka
Try to isolate your problem:

* Create the inventory

shell> cat hosts
[test]
NEXUS3172P

[test:vars]
ansible_host=10.131.88.10
ansible_network_os=nxos
username=
password=x

* Create a simple playbook

shell> cat pb.yml
- hosts: NEXUS3172P
  gather_facts: false
  tasks:
- nxos_facts:
gather_subset: hardware

* Debug the connection (-)

shell> ansible-playbook -i hosts - pb.yml


-- 
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/20230602010112.5e8a9bf3%40gmail.com.


pgp5mEigoMWbc.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Vladimir Botka
*ansible_host* and *ansible_ssh_host* are the same when you use
*ansible.builtin.ssh* connection plugin. See
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-host

In your case, *ansible_network_os=nxos* indicates that you use
*ansible.netcommon.network_cli* connection plugin. This plugin
doesn't recognise *ansible.builtin.ssh*. See
https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/network_cli_connection.html#parameter-host

-- 
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/20230602003900.4a3a12f2%40gmail.com.


pgpXT9Upoovy4.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Bikram
Yeah that's right.  ansible_host and ansible_ssh_host are the same. I tried
both options. Weird thing is complaining about dns resolution even after
using ip address.

Thanks

On Thu, Jun 1, 2023 at 5:49 PM Vladimir Botka  wrote:

> >
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-remote_user
>
> Errata
>
>
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-host
>
>
>
> --
> 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/20230601234925.24d87b60%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/CAEFfMJQzFnX16HRtK_uthTYqSh5VQbMzw_hCyo_6NeTA1%2Bxg6Q%40mail.gmail.com.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Vladimir Botka
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-remote_user

Errata

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-host



-- 
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/20230601234925.24d87b60%40gmail.com.


pgpOK8I2Vp3k5.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Vladimir Botka
On Thu, 1 Jun 2023 16:49:39 -0400
Todd Lewis  wrote:

> In your first post you were setting ansible_ssh_host=10.131.88.10, not 
> ansible_host.

Both are ansible_host and ansible_ssh_host are valid. See
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-remote_user


-- 
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/20230601234708.1e791d76%40gmail.com.


pgpfewhi2__KG.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Todd Lewis
In your first post you were setting ansible_ssh_host=10.131.88.10, not 
ansible_host.


On 6/1/23 3:56 PM, Bikram wrote:

This is really weird as I can ssh to the host with IP and Hostname.
Even though I set ansible_host=10.131.88.10 I am still getting the 
same error.




--
Todd

--
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/2ec0e787-0a24-ec49-fa93-560fa20c8ea2%40gmail.com.


Re: [ansible-project] create VM from template with customiation spec

2023-06-01 Thread Kosala Atapattu
You need to create a customization_spec in the vCenter and then refer that
using

customization_spec.



BTW, if you're on 7.0.3+, cloud-init will be the way forward.

https://github.com/ansible-collections/community.vmware/pull/1574/

*Kosala*




On Fri, Jun 2, 2023 at 2:00 AM Tony Wong  wrote:

> I want to create vm in vsphere from template and customize OS with
> customization spec
>
> I am not sure how to apply a customization spec in ansible. any idea?
>
> will something like this work
>
> ---
>
> - hosts: localhost
>
>   gather_facts: true
>
>   connection: local
>
>   vars_files:
>
> - vcenter_creds.yml
>
> - vars.yml
>
>   #no_log: True
>
>   tasks:
>
> - name: Clone the VM template and customize
>
>   vmware_guest:
>
> hostname: "{{ vcenter_hostname }}"
>
> username: "{{ vcenter_username }}"
>
> password: "{{ vcenter_password }}"
>
> validate_certs: False
>
> name: ansible-vm
>
> template: "{{ template_name }}"
>
> datacenter: "{{ datacenter_name }}"
>
> folder: "/{{ datacenter_name }}/vm/Ansible-test"
>
> cluster: "{{ cluster_name }}"
>
> datastore: "{{ datastore_name }}"
>
> networks:
>
>   - name: VLAN-111
>
> start_connected: yes
>
> ip: "{{ vm_ip }}"
>
> netmask: "{{ vm_netmask }}"
>
> gateway: "{{ vm_gateway }}"
>
> type: static
>
> dns_servers: "{{ vm_dns_servers }}"
>
> customization:
>
>   hostname: "ansible-vm"
>
>   dns_servers: "{{ vm_dns_servers }}"
>
> state: poweredon
>
> wait_for_ip_address: yes
>
>   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/b4729a2b-c090-46a2-82a8-006a1410b264n%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/CAP7S5HYoq-fUL%3D8pbefDNNpkJ4MrQyotXbRg6GNP9ajQu97HuA%40mail.gmail.com.


Re: [ansible-project] role with in a role

2023-06-01 Thread Kosala Atapattu
I think the command module now complain as well, uri module is a native way
to do what curl does.


*Kosala*




On Fri, Jun 2, 2023 at 2:49 AM Narmada Karthika 
wrote:

> I have one more question please, can we call a play in another play,
> because I have a playbook which needs to run some curl commands and fetch
> data, and the second play book has to perform the configurations.
> When I want to run configuration playbook, first it needs to run curl
> playbook and fetch data.
>
> On Wednesday, May 31, 2023 at 10:58:01 AM UTC-7 Narmada Karthika wrote:
>
>> got it..
>> thankyou
>>
>>
>> On Wednesday, May 31, 2023 at 9:55:10 AM UTC-7 Dick Visser wrote:
>>
>>> Something without the nested roles, as those are clearly not doing
>>> what you want.
>>> It's a bit hard to understand what needs to be executed where.
>>> I would start out with a playbook and not bother with roles initially.
>>>
>>> On Wed, 31 May 2023 at 17:32, Narmada Karthika 
>>> wrote:
>>> >
>>> > So, is there any other alternate solution you would suggest for my
>>> requirement.
>>> >
>>> > On Tue, May 30, 2023, 4:24 PM Kosala Atapattu 
>>> wrote:
>>> >>
>>> >> I've done this before for a complicated piece of work I did. I had
>>> roles running on several delegate proxies (yeah I called them that, since
>>> we had 5-6 of them :)).
>>> >>
>>> >> However I did not delegate a role in mycase, but all the tasks were
>>> written with delegate_to: "{{ delgate_host }}" where I can override
>>> delegate_host variable at the role level.
>>> >>
>>> >> I do not believe this is a widely used regime, and I did ran in to
>>> some issues when you call role -> role -> role, the last layer lost
>>> visibility to all the top level variables. Like @Dick Visser said this will
>>> not be the smoothest sailing, but surely works.
>>> >>
>>> >> I wrote this originally for Ansible 2.9, but when I tested with 2.11,
>>> most of the issues I faced were gone.
>>> >>
>>> >> Kosala
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Wed, May 31, 2023 at 7:42 AM Narmada Karthika 
>>> wrote:
>>> >>>
>>> >>> any suggestions please to satisfy my above request...
>>> >>>
>>> >>> On Friday, May 26, 2023 at 10:48:02 AM UTC-7 Narmada Karthika wrote:
>>> 
>>>  local host is the ansible master where the role2 has to be
>>> executed. because the role2 is to run some api commands and get server
>>> details
>>>  role1` is to install components on the server which I get from
>>> role2
>>> 
>>>  On Fri, May 26, 2023 at 10:34 AM Dick Visser 
>>> wrote:
>>> >
>>> > I haven't tried this myself (as it sounds too complicated and
>>> error prone), but I'm guessing because you first run on the remote Windows
>>> host, and from there during the other role, localhost is in fact that
>>> remote host.
>>> > It makes sense, in a way.
>>> >
>>> > I may be completely wrong though
>>> >
>>> > On Fri, 26 May 2023 at 19:24, Narmada Karthika 
>>> wrote:
>>> >>
>>> >> I am trying a playbook for a role and calling another role with
>>> in it.
>>> >> role1 where i am running playbook need to be executed on windows
>>> hosts, role 2 which is being called in role1 needs to be executed on
>>> localhost(linux).
>>> >> this is from the tasks/main.yml file for role1.
>>> >> but still it is picking windows node from role1 and failing..
>>> >> - name: calling serverdata role here
>>> >> include_role:
>>> >> name: serverdata (role2)
>>> >> tasks_from: main.yml
>>> >> apply:
>>> >> 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-proje...@googlegroups.com.
>>> >> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/18f6e3a2-5f79-43a2-9d44-2b09e18fa73en%40googlegroups.com.
>>>
>>> >
>>> > --
>>> > Sent from Gmail Mobile
>>> >
>>> > --
>>> > 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/CAF8BbLaKuC8mNa159X8ePAuVop7jCpCkYs7--hqteHRLqmy2Kw%40mail.gmail.com.
>>>
>>> 
>>> 
>>> 
>>>  --
>>>  Thanks,
>>>  Narmada Karthika Chitturi
>>> 
>>> >>>
>>> >>> --
>>> >>> 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
>>> 

Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Bikram
This is really weird as I can ssh to the host with IP and Hostname.
Even though I set ansible_host=10.131.88.10 I am still getting the same
error.

Thanks
Bikram

On Thu, Jun 1, 2023 at 3:41 PM Brian Coca  wrote:

> by default, ansilbe will use inventory_hostname as the hostname, only
> if ansilbe_host is present, will it use that.
>
> In any case, ansible itself does not 'resolve' names, it passes it to
> the connection (in this case ssh) which seems to complain that it is
> not resolvable.
>
>
> --
> --
> 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/CACVha7cJYyTrTy-fRkiC2t_FJMC5vSRRvUbm5HZ748QF1zjZiQ%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/CAEFfMJRiY-OzS0b%3DAQzbhZ1z3QQ_zHoSCq-3o2gAQsFtLQJv1Q%40mail.gmail.com.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Brian Coca
by default, ansilbe will use inventory_hostname as the hostname, only
if ansilbe_host is present, will it use that.

In any case, ansible itself does not 'resolve' names, it passes it to
the connection (in this case ssh) which seems to complain that it is
not resolvable.


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


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Bikram
Hi Brian,

Even I tried with the following in host file but the error is same:

[all]

10.131.88.10 ansible_ssh_host=10.131.88.10 ansible_network_os=nxos
username= password=x


It seems ansible is treating 'inventory_hostname' as a hostname.


In fact it knows the inventory_hostname as you see from my playbook-run
debug output.



Thanks

Bikram



On Thu, Jun 1, 2023 at 3:01 PM Brian Coca  wrote:

> not if using nxos connection plugin, as it does similar thing in the
> background w/o needing delegation.
>
> On Thu, Jun 1, 2023 at 2:57 PM 'Rowe, Walter P. (Fed)' via Ansible
> Project  wrote:
> >
> > Also, does your nxos_facts task need to "delegate_to: localhost" and use
> an API to talk to the "inventory_hostname" target?
>
>
> --
> --
> 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/CACVha7do%2Bk7oZXZvo1oGiFyEpYRETttQat_Y0Jwgfb0XSeB-cA%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/CAEFfMJSchaKSkNAks_Qegi7w6PiBcWJbqXBdNURkKWh_0fhLiA%40mail.gmail.com.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Brian Coca
not if using nxos connection plugin, as it does similar thing in the
background w/o needing delegation.

On Thu, Jun 1, 2023 at 2:57 PM 'Rowe, Walter P. (Fed)' via Ansible
Project  wrote:
>
> Also, does your nxos_facts task need to "delegate_to: localhost" and use an 
> API to talk to the "inventory_hostname" target?


-- 
--
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/CACVha7do%2Bk7oZXZvo1oGiFyEpYRETttQat_Y0Jwgfb0XSeB-cA%40mail.gmail.com.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Also, does your nxos_facts task need to "delegate_to: localhost" and use an API 
to talk to the "inventory_hostname" target?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jun 1, 2023, at 2:45 PM, Brian Coca  wrote:

I believe the message is about DNS resolution, if the inventory_hostname is not 
DNS resolvable, try setting the ip or resolvable name in the ansilbe_host 
variable in that host's scope

--
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/CACVha7do3KXQL1LBs8uL%2BXOyFMMMhkE2WiTFVQtS3ZqVpBSJew%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/C4BE5A11-F7A6-4DDE-A897-09A6DDF7A074%40nist.gov.


Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Brian Coca
I believe the message is about DNS resolution, if the inventory_hostname is
not DNS resolvable, try setting the ip or resolvable name in the
ansilbe_host variable in that host's scope

--
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/CACVha7do3KXQL1LBs8uL%2BXOyFMMMhkE2WiTFVQtS3ZqVpBSJew%40mail.gmail.com.


[ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread Bikram
Hello Team,

I am trying to run a playbook to gather facts from a nexus switch but
playbook run throws an error: 'Failed to resolve hostname
inventory_hostname'

However, in the debug message, I can see the inventory_hostname.

Here is my host file:

[all]

NEXUS3172P ansible_ssh_host=10.131.88.10 ansible_network_os=nxos
username= password=x


Below is the section of the tasks where I am getting error:
- name: '{{ msg_block }} Set CLI parameters'
  set_fact:
cli:
  host: '{{ inventory_hostname }}'
  username: '{{ username }}'
  password: '{{ password }}'
  timeout: 21600
  no_log: true

- name: '{{ msg_block }} Gather hardware info'
  block:
- name: '{{ msg_block }} Gather hardware info'
  nxos_facts:
gather_subset: hardware
provider: '{{ cli }}'
  register: device_facts

[bkb1321@ansible-server playbooks]$ ansible-playbook image_copy_nexus.yaml
-i ../hosts

Enter your finastra email: hh



PLAY [Copy image to network device]
***



TASK [debug]
**

ok: [NEXUS3172P] => {

"inventory_hostname": "NEXUS3172P"

}



TASK [NEXUS3172P Normalize variables]
*

ok: [NEXUS3172P]



TASK [NEXUS3172P Debug normalized variables]
**

skipping: [NEXUS3172P]



TASK [NEXUS3172P image_copy_cisco_nexus.yaml]
*

included: /etc/ansible/playbooks/play_image_copy_nexus.yaml for NEXUS3172P



TASK [NEXUS3172PSet CLI parameters]
***

ok: [NEXUS3172P]



TASK [NEXUS3172P Gather hardware info]


fatal: [NEXUS3172P]: FAILED! => {"ansible_facts":
{"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false,
"msg": "ssh connection failed: ssh connect failed: Failed to resolve
hostname inventory_hostname (Name or service not known)"}



TASK [set_fact]
***

ok: [NEXUS3172P]



Any help is much appreciated.



Thank you.

Bikram

-- 
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/CAEFfMJSobus8ka4OZJD3HevtPOc-EytCs0-_bJ4Tgtqu8YN2Rg%40mail.gmail.com.


Re: [ansible-project] unable to run esxcli command with ansible

2023-06-01 Thread Tony Wong
my hosts file includes the esxi host

also i am able to run "df -h" without issues

On Thu, Jun 1, 2023 at 11:13 AM Abhijeet Kasurde 
wrote:

> Are you running from the ESXi server? if not then you need to delegate
> tasks to the ESXi server which has esxcli.
>
> Please see
> https://medium.com/@AbhijeetKasurde/ansible-automating-esxcli-using-shell-module-6f691a551bca
>
>
> tl;dr -
>
> ---
> - hosts: localhost
>   gather_facts: no
>   tasks:
>   - name: Start SSH service setting for an ESXi Host in given Cluster
> vmware_host_service_manager:
>   hostname: '{{ vcenter_hostname }}'
>   username: '{{ vcenter_username }}'
>   password: '{{ vcenter_password }}'
>   esxi_hostname: '{{ item }}'
>   service_name: TSM-SSH
>   state: present
> loop: "{{ groups['esxi'] }}"
>
> - hosts: esxi
>   tasks:
> - name: Get information about all the VMs
>   shell: esxcli vm process list
>
> and
>
> [esxi]
> foo.example.com ansible_ssh_user=root
>
> On Thu, Jun 1, 2023 at 10:54 AM Tony Wong  wrote:
>
>> i got below pb
>>
>> - name: test
>>
>>   hosts: all
>>
>>   gather_facts: no
>>
>>   vars_files:
>>
>> - vcenter_creds.yml
>>
>> - vars.yml
>>
>>
>>
>>   tasks:
>>
>> - name: Enable SSH service
>>
>>   vmware_host_service_manager:
>>
>> hostname: "{{ vcenter_hostname }}"
>>
>> username: "{{ vcenter_sso_admin }}"
>>
>> password: "{{ vcenter_sso_pass }}"
>>
>> esxi_hostname: "{{ inventory_hostname }}"
>>
>> validate_certs: no
>>
>> state: present
>>
>> service_name: "TSM-SSH"
>>
>>   delegate_to: localhost
>>
>>
>>
>> - name: Esxcli
>>
>>   shell:
>>
>> cmd: "esxcli vm process list"
>>
>>   delegate_to: localhost
>>
>>   register: esxcli_output
>>
>>
>>
>> - name: Display esxcli output
>>
>>   debug:
>>
>> var: esxcli_output.stdout_lines
>>
>>
>>
>>
>>
>>
>> but keep getting error:
>>
>>
>>
>>
>> fatal: [x -> localhost]: FAILED! => {"changed": true, "cmd":
>> "esxcli", "delta": "0:00:00.009652", "end": "2023-06-01 10:49:02.878893",
>> "msg": "non-zero return code", "rc": 127, "start": "2023-06-01
>> 10:49:02.869241", "stderr": "/bin/sh: esxcli: command not found",
>> "stderr_lines": ["/bin/sh: esxcli: command not found"], "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/3d9dc4ac-0821-494b-b25f-d9e458789a6en%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Thanks,
> Abhijeet Kasurde
>
> --
> 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/adBLPTrtunI/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/CAFwWkHp4KfgvvyB%2BP3dPkBGsczuAKngpAgCVJCY3SneouO4mmA%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/CALmkhkqUBZH-3MBuxrG%2BkCpZfHJw_q2hYx5gW2vO%3DKj%2BGVpREQ%40mail.gmail.com.


Re: [ansible-project] unable to run esxcli command with ansible

2023-06-01 Thread Abhijeet Kasurde
Are you running from the ESXi server? if not then you need to delegate
tasks to the ESXi server which has esxcli.

Please see
https://medium.com/@AbhijeetKasurde/ansible-automating-esxcli-using-shell-module-6f691a551bca


tl;dr -

---
- hosts: localhost
  gather_facts: no
  tasks:
  - name: Start SSH service setting for an ESXi Host in given Cluster
vmware_host_service_manager:
  hostname: '{{ vcenter_hostname }}'
  username: '{{ vcenter_username }}'
  password: '{{ vcenter_password }}'
  esxi_hostname: '{{ item }}'
  service_name: TSM-SSH
  state: present
loop: "{{ groups['esxi'] }}"

- hosts: esxi
  tasks:
- name: Get information about all the VMs
  shell: esxcli vm process list

and

[esxi]
foo.example.com ansible_ssh_user=root

On Thu, Jun 1, 2023 at 10:54 AM Tony Wong  wrote:

> i got below pb
>
> - name: test
>
>   hosts: all
>
>   gather_facts: no
>
>   vars_files:
>
> - vcenter_creds.yml
>
> - vars.yml
>
>
>
>   tasks:
>
> - name: Enable SSH service
>
>   vmware_host_service_manager:
>
> hostname: "{{ vcenter_hostname }}"
>
> username: "{{ vcenter_sso_admin }}"
>
> password: "{{ vcenter_sso_pass }}"
>
> esxi_hostname: "{{ inventory_hostname }}"
>
> validate_certs: no
>
> state: present
>
> service_name: "TSM-SSH"
>
>   delegate_to: localhost
>
>
>
> - name: Esxcli
>
>   shell:
>
> cmd: "esxcli vm process list"
>
>   delegate_to: localhost
>
>   register: esxcli_output
>
>
>
> - name: Display esxcli output
>
>   debug:
>
> var: esxcli_output.stdout_lines
>
>
>
>
>
>
> but keep getting error:
>
>
>
>
> fatal: [x -> localhost]: FAILED! => {"changed": true, "cmd":
> "esxcli", "delta": "0:00:00.009652", "end": "2023-06-01 10:49:02.878893",
> "msg": "non-zero return code", "rc": 127, "start": "2023-06-01
> 10:49:02.869241", "stderr": "/bin/sh: esxcli: command not found",
> "stderr_lines": ["/bin/sh: esxcli: command not found"], "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/3d9dc4ac-0821-494b-b25f-d9e458789a6en%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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHp4KfgvvyB%2BP3dPkBGsczuAKngpAgCVJCY3SneouO4mmA%40mail.gmail.com.


Re: [ansible-project] role with in a role

2023-06-01 Thread Mike Eggleston
import_plays and import_playbookMikeOn Jun 1, 2023, at 12:15, Dick Visser  wrote:You can have a playbook with multiple plays. One targets localhost to fetch api results. You register that. The subsequent plays target real host and use the registered data On Thu, 1 Jun 2023 at 16:50, Narmada Karthika  wrote:I have one more question please, can we call a play in another play, because I have a playbook which needs to run some curl commands and fetch data, and the second play book has to perform the configurations. When I want to run configuration playbook, first it needs to run curl playbook and fetch data. On Wednesday, May 31, 2023 at 10:58:01 AM UTC-7 Narmada Karthika wrote:got it.. thankyouOn Wednesday, May 31, 2023 at 9:55:10 AM UTC-7 Dick Visser wrote:Something without the nested roles, as those are clearly not doing
what you want.
It's a bit hard to understand what needs to be executed where.
I would start out with a playbook and not bother with roles initially.

On Wed, 31 May 2023 at 17:32, Narmada Karthika  wrote:
>
> So, is there any other alternate solution you would suggest  for my requirement.
>
> On Tue, May 30, 2023, 4:24 PM Kosala Atapattu  wrote:
>>
>> I've done this before for a complicated piece of work I did. I had roles running on several delegate proxies (yeah I called them that, since we had 5-6 of them :)).
>>
>> However I did not delegate a role in mycase, but all the tasks were written with delegate_to: "{{ delgate_host }}" where I can override delegate_host variable at the role level.
>>
>> I do not believe this is a widely used regime, and I did ran in to some issues when you call role -> role -> role, the last layer lost visibility to all the top level variables. Like @Dick Visser said this will not be the smoothest sailing, but surely works.
>>
>> I wrote this originally for Ansible 2.9, but when I tested with 2.11, most of the issues I faced were gone.
>>
>> Kosala
>>
>>
>>
>>
>> On Wed, May 31, 2023 at 7:42 AM Narmada Karthika  wrote:
>>>
>>> any suggestions please to satisfy my above request...
>>>
>>> On Friday, May 26, 2023 at 10:48:02 AM UTC-7 Narmada Karthika wrote:

 local host is the ansible master where the role2 has to be executed. because the role2 is to run some api commands and get server details
 role1` is to install components on the server which I get from role2

 On Fri, May 26, 2023 at 10:34 AM Dick Visser  wrote:
>
> I haven't tried this myself (as it sounds too complicated and error prone), but I'm guessing because you first run on the remote Windows  host, and from there during the other role, localhost is in fact that remote host.
> It makes sense, in a way.
>
> I may be completely wrong though
>
> On Fri, 26 May 2023 at 19:24, Narmada Karthika  wrote:
>>
>> I am trying a playbook for a role and calling another role with in it.
>> role1 where i am running playbook need to be executed on windows hosts, role 2 which is being called in role1 needs to be executed on localhost(linux).
>> this is from the tasks/main.yml file for role1.
>> but still it is picking windows node from role1 and failing..
>> - name: calling serverdata role here
>>   include_role:
>> name: serverdata (role2)
>> tasks_from: main.yml
>> apply:
>>   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-proje...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/18f6e3a2-5f79-43a2-9d44-2b09e18fa73en%40googlegroups.com.
>
> --
> Sent from Gmail Mobile
>
> --
> 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/CAF8BbLaKuC8mNa159X8ePAuVop7jCpCkYs7--hqteHRLqmy2Kw%40mail.gmail.com.



 --
  Thanks,
 Narmada Karthika Chitturi

>>>
>>> --
>>> 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/1f82284f-386c-4389-a269-474dd5d0a38cn%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 

[ansible-project] unable to run esxcli command with ansible

2023-06-01 Thread Tony Wong
i got below pb

- name: test

  hosts: all

  gather_facts: no

  vars_files:

- vcenter_creds.yml

- vars.yml

 

  tasks:

- name: Enable SSH service

  vmware_host_service_manager:

hostname: "{{ vcenter_hostname }}"

username: "{{ vcenter_sso_admin }}"

password: "{{ vcenter_sso_pass }}"

esxi_hostname: "{{ inventory_hostname }}"

validate_certs: no

state: present

service_name: "TSM-SSH"

  delegate_to: localhost

 

- name: Esxcli

  shell:

cmd: "esxcli vm process list"

  delegate_to: localhost

  register: esxcli_output

 

- name: Display esxcli output

  debug:

var: esxcli_output.stdout_lines






but keep getting error: 




fatal: [x -> localhost]: FAILED! => {"changed": true, "cmd": 
"esxcli", "delta": "0:00:00.009652", "end": "2023-06-01 10:49:02.878893", 
"msg": "non-zero return code", "rc": 127, "start": "2023-06-01 
10:49:02.869241", "stderr": "/bin/sh: esxcli: command not found", 
"stderr_lines": ["/bin/sh: esxcli: command not found"], "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/3d9dc4ac-0821-494b-b25f-d9e458789a6en%40googlegroups.com.


Re: [ansible-project] role with in a role

2023-06-01 Thread Dick Visser
You can have a playbook with multiple plays. One targets localhost to fetch
api results. You register that.
The subsequent plays target real host and use the registered data


On Thu, 1 Jun 2023 at 16:50, Narmada Karthika  wrote:

> I have one more question please, can we call a play in another play,
> because I have a playbook which needs to run some curl commands and fetch
> data, and the second play book has to perform the configurations.
> When I want to run configuration playbook, first it needs to run curl
> playbook and fetch data.
>
> On Wednesday, May 31, 2023 at 10:58:01 AM UTC-7 Narmada Karthika wrote:
>
>> got it..
>> thankyou
>>
>>
>> On Wednesday, May 31, 2023 at 9:55:10 AM UTC-7 Dick Visser wrote:
>>
>>> Something without the nested roles, as those are clearly not doing
>>> what you want.
>>> It's a bit hard to understand what needs to be executed where.
>>> I would start out with a playbook and not bother with roles initially.
>>>
>>> On Wed, 31 May 2023 at 17:32, Narmada Karthika 
>>> wrote:
>>> >
>>> > So, is there any other alternate solution you would suggest for my
>>> requirement.
>>> >
>>> > On Tue, May 30, 2023, 4:24 PM Kosala Atapattu 
>>> wrote:
>>> >>
>>> >> I've done this before for a complicated piece of work I did. I had
>>> roles running on several delegate proxies (yeah I called them that, since
>>> we had 5-6 of them :)).
>>> >>
>>> >> However I did not delegate a role in mycase, but all the tasks were
>>> written with delegate_to: "{{ delgate_host }}" where I can override
>>> delegate_host variable at the role level.
>>> >>
>>> >> I do not believe this is a widely used regime, and I did ran in to
>>> some issues when you call role -> role -> role, the last layer lost
>>> visibility to all the top level variables. Like @Dick Visser said this will
>>> not be the smoothest sailing, but surely works.
>>> >>
>>> >> I wrote this originally for Ansible 2.9, but when I tested with 2.11,
>>> most of the issues I faced were gone.
>>> >>
>>> >> Kosala
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Wed, May 31, 2023 at 7:42 AM Narmada Karthika 
>>> wrote:
>>> >>>
>>> >>> any suggestions please to satisfy my above request...
>>> >>>
>>> >>> On Friday, May 26, 2023 at 10:48:02 AM UTC-7 Narmada Karthika wrote:
>>> 
>>>  local host is the ansible master where the role2 has to be
>>> executed. because the role2 is to run some api commands and get server
>>> details
>>>  role1` is to install components on the server which I get from
>>> role2
>>> 
>>>  On Fri, May 26, 2023 at 10:34 AM Dick Visser 
>>> wrote:
>>> >
>>> > I haven't tried this myself (as it sounds too complicated and
>>> error prone), but I'm guessing because you first run on the remote Windows
>>> host, and from there during the other role, localhost is in fact that
>>> remote host.
>>> > It makes sense, in a way.
>>> >
>>> > I may be completely wrong though
>>> >
>>> > On Fri, 26 May 2023 at 19:24, Narmada Karthika 
>>> wrote:
>>> >>
>>> >> I am trying a playbook for a role and calling another role with
>>> in it.
>>> >> role1 where i am running playbook need to be executed on windows
>>> hosts, role 2 which is being called in role1 needs to be executed on
>>> localhost(linux).
>>> >> this is from the tasks/main.yml file for role1.
>>> >> but still it is picking windows node from role1 and failing..
>>> >> - name: calling serverdata role here
>>> >> include_role:
>>> >> name: serverdata (role2)
>>> >> tasks_from: main.yml
>>> >> apply:
>>> >> 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-proje...@googlegroups.com.
>>> >> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/18f6e3a2-5f79-43a2-9d44-2b09e18fa73en%40googlegroups.com.
>>>
>>> >
>>> > --
>>> > Sent from Gmail Mobile
>>> >
>>> > --
>>> > 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/CAF8BbLaKuC8mNa159X8ePAuVop7jCpCkYs7--hqteHRLqmy2Kw%40mail.gmail.com.
>>>
>>> 
>>> 
>>> 
>>>  --
>>>  Thanks,
>>>  Narmada Karthika Chitturi
>>> 
>>> >>>
>>> >>> --
>>> >>> 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
>>> 

Re: [ansible-project] role with in a role

2023-06-01 Thread Narmada Karthika
I have one more question please, can we call a play in another play, 
because I have a playbook which needs to run some curl commands and fetch 
data, and the second play book has to perform the configurations. 
When I want to run configuration playbook, first it needs to run curl 
playbook and fetch data. 

On Wednesday, May 31, 2023 at 10:58:01 AM UTC-7 Narmada Karthika wrote:

> got it.. 
> thankyou
>
>
> On Wednesday, May 31, 2023 at 9:55:10 AM UTC-7 Dick Visser wrote:
>
>> Something without the nested roles, as those are clearly not doing 
>> what you want. 
>> It's a bit hard to understand what needs to be executed where. 
>> I would start out with a playbook and not bother with roles initially. 
>>
>> On Wed, 31 May 2023 at 17:32, Narmada Karthika  
>> wrote: 
>> > 
>> > So, is there any other alternate solution you would suggest for my 
>> requirement. 
>> > 
>> > On Tue, May 30, 2023, 4:24 PM Kosala Atapattu  
>> wrote: 
>> >> 
>> >> I've done this before for a complicated piece of work I did. I had 
>> roles running on several delegate proxies (yeah I called them that, since 
>> we had 5-6 of them :)). 
>> >> 
>> >> However I did not delegate a role in mycase, but all the tasks were 
>> written with delegate_to: "{{ delgate_host }}" where I can override 
>> delegate_host variable at the role level. 
>> >> 
>> >> I do not believe this is a widely used regime, and I did ran in to 
>> some issues when you call role -> role -> role, the last layer lost 
>> visibility to all the top level variables. Like @Dick Visser said this will 
>> not be the smoothest sailing, but surely works. 
>> >> 
>> >> I wrote this originally for Ansible 2.9, but when I tested with 2.11, 
>> most of the issues I faced were gone. 
>> >> 
>> >> Kosala 
>> >> 
>> >> 
>> >> 
>> >> 
>> >> On Wed, May 31, 2023 at 7:42 AM Narmada Karthika  
>> wrote: 
>> >>> 
>> >>> any suggestions please to satisfy my above request... 
>> >>> 
>> >>> On Friday, May 26, 2023 at 10:48:02 AM UTC-7 Narmada Karthika wrote: 
>>  
>>  local host is the ansible master where the role2 has to be executed. 
>> because the role2 is to run some api commands and get server details 
>>  role1` is to install components on the server which I get from role2 
>>  
>>  On Fri, May 26, 2023 at 10:34 AM Dick Visser  
>> wrote: 
>> > 
>> > I haven't tried this myself (as it sounds too complicated and error 
>> prone), but I'm guessing because you first run on the remote Windows host, 
>> and from there during the other role, localhost is in fact that remote 
>> host. 
>> > It makes sense, in a way. 
>> > 
>> > I may be completely wrong though 
>> > 
>> > On Fri, 26 May 2023 at 19:24, Narmada Karthika  
>> wrote: 
>> >> 
>> >> I am trying a playbook for a role and calling another role with in 
>> it. 
>> >> role1 where i am running playbook need to be executed on windows 
>> hosts, role 2 which is being called in role1 needs to be executed on 
>> localhost(linux). 
>> >> this is from the tasks/main.yml file for role1. 
>> >> but still it is picking windows node from role1 and failing.. 
>> >> - name: calling serverdata role here 
>> >> include_role: 
>> >> name: serverdata (role2) 
>> >> tasks_from: main.yml 
>> >> apply: 
>> >> 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-proje...@googlegroups.com. 
>> >> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/18f6e3a2-5f79-43a2-9d44-2b09e18fa73en%40googlegroups.com.
>>  
>>
>> > 
>> > -- 
>> > Sent from Gmail Mobile 
>> > 
>> > -- 
>> > 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/CAF8BbLaKuC8mNa159X8ePAuVop7jCpCkYs7--hqteHRLqmy2Kw%40mail.gmail.com.
>>  
>>
>>  
>>  
>>  
>>  -- 
>>  Thanks, 
>>  Narmada Karthika Chitturi 
>>  
>> >>> 
>> >>> -- 
>> >>> 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/1f82284f-386c-4389-a269-474dd5d0a38cn%40googlegroups.com.
>>  
>>
>> >> 
>> >> -- 
>> >> You received this message because you are subscribed to the Google 
>> Groups "Ansible Project" group. 
>> >> To unsubscribe from this group and 

[ansible-project] create VM from template with customiation spec

2023-06-01 Thread Tony Wong
I want to create vm in vsphere from template and customize OS with 
customization spec

I am not sure how to apply a customization spec in ansible. any idea?

will something like this work

---

- hosts: localhost

  gather_facts: true

  connection: local

  vars_files:

- vcenter_creds.yml

- vars.yml

  #no_log: True 

  tasks:

- name: Clone the VM template and customize

  vmware_guest:

hostname: "{{ vcenter_hostname }}"

username: "{{ vcenter_username }}"

password: "{{ vcenter_password }}"

validate_certs: False

name: ansible-vm

template: "{{ template_name }}"

datacenter: "{{ datacenter_name }}"

folder: "/{{ datacenter_name }}/vm/Ansible-test"

cluster: "{{ cluster_name }}"

datastore: "{{ datastore_name }}"

networks:

  - name: VLAN-111

start_connected: yes

ip: "{{ vm_ip }}"

netmask: "{{ vm_netmask }}"

gateway: "{{ vm_gateway }}"

type: static

dns_servers: "{{ vm_dns_servers }}"

customization:

  hostname: "ansible-vm"

  dns_servers: "{{ vm_dns_servers }}"

state: poweredon

wait_for_ip_address: yes

  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/b4729a2b-c090-46a2-82a8-006a1410b264n%40googlegroups.com.


Fwd: [ansible-project] role with in a role

2023-06-01 Thread Narmada Karthika
-- Forwarded message -
From: Narmada Karthika 
Date: Thu, Jun 1, 2023, 6:31 AM
Subject: Re: [ansible-project] role with in a role
To: 


I have one more question please, can we call a play in another play,
because I have a playbook which needs to run some curl commands and fetch
data, and the second play book has to perform the configurations.
When I want to run configuration playbook, first it needs to run curl
playbook and fetch data.



On Wed, May 31, 2023, 9:55 AM Dick Visser  wrote:

> Something without the nested roles, as those are clearly not doing
> what you want.
> It's a bit hard to understand what needs to be executed where.
> I would start out with a playbook and not bother with roles initially.
>
> On Wed, 31 May 2023 at 17:32, Narmada Karthika 
> wrote:
> >
> > So, is there any other alternate solution you would suggest  for my
> requirement.
> >
> > On Tue, May 30, 2023, 4:24 PM Kosala Atapattu 
> wrote:
> >>
> >> I've done this before for a complicated piece of work I did. I had
> roles running on several delegate proxies (yeah I called them that, since
> we had 5-6 of them :)).
> >>
> >> However I did not delegate a role in mycase, but all the tasks were
> written with delegate_to: "{{ delgate_host }}" where I can override
> delegate_host variable at the role level.
> >>
> >> I do not believe this is a widely used regime, and I did ran in to some
> issues when you call role -> role -> role, the last layer lost visibility
> to all the top level variables. Like @Dick Visser said this will not be the
> smoothest sailing, but surely works.
> >>
> >> I wrote this originally for Ansible 2.9, but when I tested with 2.11,
> most of the issues I faced were gone.
> >>
> >> Kosala
> >>
> >>
> >>
> >>
> >> On Wed, May 31, 2023 at 7:42 AM Narmada Karthika 
> wrote:
> >>>
> >>> any suggestions please to satisfy my above request...
> >>>
> >>> On Friday, May 26, 2023 at 10:48:02 AM UTC-7 Narmada Karthika wrote:
> 
>  local host is the ansible master where the role2 has to be executed.
> because the role2 is to run some api commands and get server details
>  role1` is to install components on the server which I get from role2
> 
>  On Fri, May 26, 2023 at 10:34 AM Dick Visser 
> wrote:
> >
> > I haven't tried this myself (as it sounds too complicated and error
> prone), but I'm guessing because you first run on the remote Windows  host,
> and from there during the other role, localhost is in fact that remote host.
> > It makes sense, in a way.
> >
> > I may be completely wrong though
> >
> > On Fri, 26 May 2023 at 19:24, Narmada Karthika 
> wrote:
> >>
> >> I am trying a playbook for a role and calling another role with in
> it.
> >> role1 where i am running playbook need to be executed on windows
> hosts, role 2 which is being called in role1 needs to be executed on
> localhost(linux).
> >> this is from the tasks/main.yml file for role1.
> >> but still it is picking windows node from role1 and failing..
> >> - name: calling serverdata role here
> >>   include_role:
> >> name: serverdata (role2)
> >> tasks_from: main.yml
> >> apply:
> >>   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-proje...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/18f6e3a2-5f79-43a2-9d44-2b09e18fa73en%40googlegroups.com
> .
> >
> > --
> > Sent from Gmail Mobile
> >
> > --
> > 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/CAF8BbLaKuC8mNa159X8ePAuVop7jCpCkYs7--hqteHRLqmy2Kw%40mail.gmail.com
> .
> 
> 
> 
>  --
>   Thanks,
>  Narmada Karthika Chitturi
> 
> >>>
> >>> --
> >>> 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/1f82284f-386c-4389-a269-474dd5d0a38cn%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
>