Re: [ansible-project] Re: Working around lookup plugin limitation with environment variables

2020-07-22 Thread Dick Visser
Your setting it in one play and then try to use it in another. That won't
work.

Other question. You run this sts task for all hosts, but is that needed for
all of them?


On Thu, 23 Jul 2020 at 04:59, Nico H  wrote:

> Thank you for the proposition, I ve been trying for days to put  this in
> every direction I could but unfortunately 'environment '
> was never  passed to 'import_role' .
> I am not sure how to investigate about import_role module and why
> environment is not supported , seems impossible to reuse sts.creds then .
> Any idea is welcome
>
>
> Hi all,
>>
>> I'm looking for any suggestions on how to work around the following issue:
>>
>> I am trying to use a lookup plugin but it is ignoring my environment
>> variables.
>>
>> The lookup plugin I am trying to use is credstash and the environment
>> variables are being set because I am using AWS STS to assume a role.
>>
>> It looks a little like this:
>>
>> ---
>> - name: Get STS token
>>   hosts: "{{ hosts }}"
>>   connection: local
>>   tasks:
>> - name: Assume role for passed account
>>   sts_assume_role:
>> region: "{{ aws_region }}"
>> role_arn: "arn:aws:iam::{{ aws_account_id }}:role/ansible-is_assumed"
>> role_session_name: ansible_assumed_role
>>   register: assumed_role
>>   when: use_sts
>>
>> - name: Set environment with AWS creds when available
>>   set_fact:
>> my_environment:
>>   AWS_ACCESS_KEY_ID: "{{ assumed_role.sts_creds.access_key }}"
>>   AWS_SECRET_ACCESS_KEY: "{{ assumed_role.sts_creds.secret_key }}"
>>   AWS_SECURITY_TOKEN: "{{ assumed_role.sts_creds.session_token }}"
>>   when: assumed_role.skipped is not defined
>>
>> - name: Set environment blank when no AWS creds
>>   set_fact:
>> my_environment: {}
>>   when: assumed_role.skipped is defined
>>
>> - name: Deploy infrastructure role
>>   hosts: "{{ hosts }}"
>>   connection: local
>>   roles:
>> - "{{ role_to_deploy }}"
>>   environment: "{{ my_environment }}"
>>
>>
>>
>> Now in the role_to_deploy i have lots of tasks that work brilliantly
>> calling out to AWS using the STS credentials supplied as intended.
>>
>> Unfortunately, any lookup plugins do not work properly because they do
>> not use the environment variables I have set.  They end up calling out to
>> AWS using the default credentials rather than being overridden by the STS
>> creds.
>>
>> I don't think this is a bug but it is never the less annoying.
>>
>> I'm hoping maybe one of the core team can think of a way I can get the
>> lookup plugin to 'see' my STS environment variables I have set.
>>
> --
> 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/b52315eb-366c-48b6-b377-d2f745bb5452o%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMYhNwaN07Sscbyq%2BYkh5fvAYOUfmTzrCWnRZG34on3gQ%40mail.gmail.com.


[ansible-project] Re: Working around lookup plugin limitation with environment variables

2020-07-22 Thread Nico H
Thank you for the proposition, I ve been trying for days to put  this in 
every direction I could but unfortunately 'environment '
was never  passed to 'import_role' .
I am not sure how to investigate about import_role module and why 
environment is not supported , seems impossible to reuse sts.creds then .
Any idea is welcome 


Hi all,
>
> I'm looking for any suggestions on how to work around the following issue:
>
> I am trying to use a lookup plugin but it is ignoring my environment 
> variables.
>
> The lookup plugin I am trying to use is credstash and the environment 
> variables are being set because I am using AWS STS to assume a role.
>
> It looks a little like this:
>
> ---
> - name: Get STS token
>   hosts: "{{ hosts }}"
>   connection: local
>   tasks:
> - name: Assume role for passed account
>   sts_assume_role:
> region: "{{ aws_region }}"
> role_arn: "arn:aws:iam::{{ aws_account_id }}:role/ansible-is_assumed"
> role_session_name: ansible_assumed_role
>   register: assumed_role
>   when: use_sts
>
> - name: Set environment with AWS creds when available
>   set_fact:
> my_environment:
>   AWS_ACCESS_KEY_ID: "{{ assumed_role.sts_creds.access_key }}"
>   AWS_SECRET_ACCESS_KEY: "{{ assumed_role.sts_creds.secret_key }}"
>   AWS_SECURITY_TOKEN: "{{ assumed_role.sts_creds.session_token }}"
>   when: assumed_role.skipped is not defined
>
> - name: Set environment blank when no AWS creds
>   set_fact:
> my_environment: {}
>   when: assumed_role.skipped is defined
>
> - name: Deploy infrastructure role
>   hosts: "{{ hosts }}"
>   connection: local
>   roles:
> - "{{ role_to_deploy }}"
>   environment: "{{ my_environment }}"
>
>
>
> Now in the role_to_deploy i have lots of tasks that work brilliantly 
> calling out to AWS using the STS credentials supplied as intended.
>
> Unfortunately, any lookup plugins do not work properly because they do not 
> use the environment variables I have set.  They end up calling out to AWS 
> using the default credentials rather than being overridden by the STS creds.
>
> I don't think this is a bug but it is never the less annoying.
>
> I'm hoping maybe one of the core team can think of a way I can get the 
> lookup plugin to 'see' my STS environment variables I have set.
>

-- 
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/b52315eb-366c-48b6-b377-d2f745bb5452o%40googlegroups.com.


[ansible-project] Trouble with python bindings error (libselinux-python not installed) on RHEL8

2020-07-22 Thread Robbie
Hello all. 

I've been trying to troubleshoot a problem for days and I haven't been able 
to find anything online that refers to RHEL8/Centos8.I have success running 
on RHEL/Centos7, but I'm trying to push to the new platform. Ikeep getting 
this error:
TASK [genjson: Generate F5 JSON - Nodes] 

task path: /home/admsplitb/Lab-Infrastructure/roles/f5_dclb/tasks/main.yml:6
fatal: [genjson-1]: FAILED! => {"changed": false, "checksum": 
"60caf69c5c72c2814e3b1688a9564a86205778ed", "msg": "Aborting, target uses 
selinux but python bindings (libselinux-python) aren't installed!"}


My version of ansible and python
(py3venv) [user@lab playbooks]$ ansible --version
ansible 2.9.11
  config file = /home/user/Lab-Infrastructure/playbooks/ansible.cfg
  ansible python module location = /home/user/py3venv/lib64/python3.8/site-
packages/ansible
  executable location = /home/user/py3venv/bin/ansible
  python version = 3.8.0 (default, Mar  9 2020, 18:02:46) [GCC 8.3.1 
20191121 (Red Hat 8.3.1-5)]


I tried to link previous packages as indicated in this github issue 


First ensuring that the packages are installed: 

yum install libselinux-python

And then linking the files to your environment.
cd ~/py3venv/lib64/python3.8/site-packages/
ln -s /usr/lib64/python3.6/site-packages/selinux
ln -s /usr/lib64/python3.6/site-packages/_selinux.cpython-36m-x86_64-linux-
gnu.so


But in RHEL8, the package names have changed. 
yum install libselinux
yum install python3-libselinux


Anybody experience this and solve it yet?

-- 
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/bd330518-df01-4b93-a98d-20fd1f1354feo%40googlegroups.com.


Re: [ansible-project] setting up a new system with Ansible

2020-07-22 Thread John Petro
That is pretty close to what I am doing.  The only thing I want to do
differently, is that I want to lock the automation account, so that it's
only accepted from a specific host.  ( ie. the ansible control node)

--jp

On Tue, Jul 21, 2020 at 9:23 PM Ed Wong  wrote:

> Hi,
>
> I've played with Ansible before but hadn't really done much in terms of
> maintaining a whole infrastructure.  I'm hoping to restart my foray into it
> in hopes to migrate off of the old way of standing up systems.  I wish to
> migrate to using Ansible to manage the whole infrastructure.  That said,
> I'm starting off simple.  I'm not touching the existing systems.  I have a
> basic control node and just set up a minimal CentOS 7 system.
>
> Here is where i"m a tad bit confused in what I need to do and if someone
> can clarify things, I'd be appreciated.
>
> Is the following process correct?
>
> 1) Log on to Alpha and create a new user, say automation.
> 2) create ssh keys for automation.
> 3) allow automation to have sudo access w/ no password.
> 4) copy ssh credentials to control node.
>
> Is this the very first thing one does for every new system?  (Granted, I
> won't need to create new ssh-keys as I just need to copy the original ones
> to the new system).
> My understanding of this process is that in order to manage any system, I
> need  a user that can have access to said system.  Once I have that user
> set up properly,
> I won't need to even log in manually to do things.
>
> Thanks for the clarifications.
>
> Ed
>
>
>
> --
> 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/a03a88cf-d05a-42b9-81ff-e594085d3b0bo%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/CAPAjob-LE-5ji_kYSbMrSfn7o%3DSg9j-OSvqBFYvn9vXXMMxEAQ%40mail.gmail.com.


[ansible-project] Re: sensible-cmdb Default Columns

2020-07-22 Thread Marlon Hester
auto-correct messed up my title. I meant Ansible-cmdb. 

On Wednesday, July 22, 2020 at 2:45:22 PM UTC-4, Marlon Hester wrote:
>
> Hello anyone and everyone,
>
> I've been using ansible-cmdb to generate an inventory webpage. I am trying 
> to specify the "shown columns"  that show by default. I am aware of the 
> "-c" option however when I use it, it removes the other unused columns. I 
> want all column buttons to show but I want to be able to customize which 
> one's are shown under the "host overview". 
>
> I've tried to use sed to perform mods directly to the .html page but it's 
> not providing the expected output. 
>

-- 
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/acd8dbda-770b-403a-8e11-c3c3b1efd3e6o%40googlegroups.com.


[ansible-project] sensible-cmdb Default Columns

2020-07-22 Thread Marlon Hester
Hello anyone and everyone,

I've been using ansible-cmdb to generate an inventory webpage. I am trying 
to specify the "shown columns"  that show by default. I am aware of the 
"-c" option however when I use it, it removes the other unused columns. I 
want all column buttons to show but I want to be able to customize which 
one's are shown under the "host overview". 

I've tried to use sed to perform mods directly to the .html page but it's 
not providing the expected output. 

-- 
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/a3687a05-2c4e-42eb-a464-c78e7fa3bbd9o%40googlegroups.com.


[ansible-project] Ansible for Cisco switchport interface and 802.1x config

2020-07-22 Thread Waqas Gondal
Hi

 

I am working on putting Cisco ISE into enforcement mode on production Cisco 
switches for 802.1x wired authentication.

 

Currently the access interfaces all have 'authentication open' which needs 
to be removed.

 

I have Ansible installed and ready to configure switches.

 

Is there anyway I could configure a playbook to find access ports that have 
'authentication open' and remove it?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f96efc9a-3de0-4781-b233-b7595f5ed4b5o%40googlegroups.com.


Re: [ansible-project] How to debug a community ansible module ?

2020-07-22 Thread Charles Moulliard
Sorry but I don't see how I could debug the code with a breakpoint declared
within my IDEA tool using this command "ansible localhost -m ping -a
'data=debugging_session' -vvv" ...

On Wed, Jul 22, 2020 at 3:51 PM Matt Martz  wrote:

> `ansible_collections` is the python module that the code will try to load,
> so you cannot contain that in your PYTHONPATH, you need to set your
> PYTHONPATH to the directory that contains the ansible_collections directory.
>
> fwiw, I wouldn't recommend using this as the primary means to test or
> debug a module.
>
> Follow the docs outlined at
> https://docs.ansible.com/ansible/devel/dev_guide/debugging.html#debugging-ansiblemodule-based-modules
>
> If you bypass the normal execution flow, you aren't properly testing the
> module.
>
> On Wed, Jul 22, 2020 at 8:45 AM Charles Moulliard 
> wrote:
>
>> That fails if I try what you suggest as the project (I suppose) is no
>> installed as a collection but git cloned
>>
>> (.venv)  ~/code/ansible/ansible_collections $
>> PYTHONPATH=/Users/cmoullia/code/ansible/ansible_collections python3
>> community/kubernetes/plugins/modules/k8s_log.py
>> Traceback (most recent call last):
>>   File "community/kubernetes/plugins/modules/k8s_log.py", line 131, in
>> 
>> from
>> ansible_collections.community.kubernetes.plugins.module_utils.common import
>> KubernetesAnsibleModule
>> ModuleNotFoundError: No module named 'ansible_collections'
>>
>>
>> On Wed, Jul 22, 2020 at 2:48 PM Abhijeet Kasurde 
>> wrote:
>>
>>> Try adding PYTHONPATH
>>>
>>> For me it is like
>>> PYTHONPATH=/Volumes/data/src/ansible/lib:/Volumes/data/src/ansible:/Volumes/data/src/collections
>>> /Volumes/data/venv3/bin/python 
>>>
>>> On Wed, Jul 22, 2020 at 6:10 PM cmou...@redhat.com 
>>> wrote:
>>>
 Hi,

 As the packages to be imported by a python file are prefixed as
 "ansible_collections.", how can we then locally debug an Ansible Module

 Example:
 https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_log.py

 from
 ansible_collections.community.kubernetes.plugins.module_utils.common import
 KubernetesAnsibleModule
 ...

 class KubernetesLogModule(KubernetesAnsibleModule):

 def __init__(self, *args, **kwargs):
 KubernetesAnsibleModule.__init__(self, *args,
  supports_check_mode=True,
  **kwargs)

 Result

 /usr/local/bin/python3.7 "/Users/cmoullia/Library/Application
 Support/JetBrains/IntelliJIdea2020.1/plugins/python/helpers/pydev/pydevd.py"
 --multiproc --qt-support=auto --client 127.0.0.1 --port 57135 --file
 /Users/cmoullia/code/ansible/community.kubernetes/plugins/modules/k8s_log.py
 pydev debugger: process 68087 is connecting

 Connected to pydev debugger (build 201.8538.31)
 Traceback (most recent call last):
   File "", line 983, in _find_and_load
   File "", line 953, in
 _find_and_load_unlocked
   File "", line 219, in
 _call_with_frames_removed
 ModuleNotFoundError: No module named 'ansible_collections'

 Best

 Charles



 --
 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/386a706d-859f-429b-b100-d3d88ce1d3e8n%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/SlDn22N-1zM/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/CAFwWkHoGSb4T93_UefwDXBKunB_LUzs4TyTjf8pwhLE1H7cjZA%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/CAPb1sSs6x0QN_ivMWyMaPCy1VJx_xEeFML%3Duqm50cz6UqFjBTQ%40mail.gmail.com
>> 

Re: [ansible-project] How to debug a community ansible module ?

2020-07-22 Thread Matt Martz
`ansible_collections` is the python module that the code will try to load,
so you cannot contain that in your PYTHONPATH, you need to set your
PYTHONPATH to the directory that contains the ansible_collections directory.

fwiw, I wouldn't recommend using this as the primary means to test or debug
a module.

Follow the docs outlined at
https://docs.ansible.com/ansible/devel/dev_guide/debugging.html#debugging-ansiblemodule-based-modules

If you bypass the normal execution flow, you aren't properly testing the
module.

On Wed, Jul 22, 2020 at 8:45 AM Charles Moulliard 
wrote:

> That fails if I try what you suggest as the project (I suppose) is no
> installed as a collection but git cloned
>
> (.venv)  ~/code/ansible/ansible_collections $
> PYTHONPATH=/Users/cmoullia/code/ansible/ansible_collections python3
> community/kubernetes/plugins/modules/k8s_log.py
> Traceback (most recent call last):
>   File "community/kubernetes/plugins/modules/k8s_log.py", line 131, in
> 
> from
> ansible_collections.community.kubernetes.plugins.module_utils.common import
> KubernetesAnsibleModule
> ModuleNotFoundError: No module named 'ansible_collections'
>
>
> On Wed, Jul 22, 2020 at 2:48 PM Abhijeet Kasurde 
> wrote:
>
>> Try adding PYTHONPATH
>>
>> For me it is like
>> PYTHONPATH=/Volumes/data/src/ansible/lib:/Volumes/data/src/ansible:/Volumes/data/src/collections
>> /Volumes/data/venv3/bin/python 
>>
>> On Wed, Jul 22, 2020 at 6:10 PM cmou...@redhat.com 
>> wrote:
>>
>>> Hi,
>>>
>>> As the packages to be imported by a python file are prefixed as
>>> "ansible_collections.", how can we then locally debug an Ansible Module
>>>
>>> Example:
>>> https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_log.py
>>>
>>> from
>>> ansible_collections.community.kubernetes.plugins.module_utils.common import
>>> KubernetesAnsibleModule
>>> ...
>>>
>>> class KubernetesLogModule(KubernetesAnsibleModule):
>>>
>>> def __init__(self, *args, **kwargs):
>>> KubernetesAnsibleModule.__init__(self, *args,
>>>  supports_check_mode=True,
>>>  **kwargs)
>>>
>>> Result
>>>
>>> /usr/local/bin/python3.7 "/Users/cmoullia/Library/Application
>>> Support/JetBrains/IntelliJIdea2020.1/plugins/python/helpers/pydev/pydevd.py"
>>> --multiproc --qt-support=auto --client 127.0.0.1 --port 57135 --file
>>> /Users/cmoullia/code/ansible/community.kubernetes/plugins/modules/k8s_log.py
>>> pydev debugger: process 68087 is connecting
>>>
>>> Connected to pydev debugger (build 201.8538.31)
>>> Traceback (most recent call last):
>>>   File "", line 983, in _find_and_load
>>>   File "", line 953, in
>>> _find_and_load_unlocked
>>>   File "", line 219, in
>>> _call_with_frames_removed
>>> ModuleNotFoundError: No module named 'ansible_collections'
>>>
>>> Best
>>>
>>> Charles
>>>
>>>
>>>
>>> --
>>> 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/386a706d-859f-429b-b100-d3d88ce1d3e8n%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/SlDn22N-1zM/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/CAFwWkHoGSb4T93_UefwDXBKunB_LUzs4TyTjf8pwhLE1H7cjZA%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/CAPb1sSs6x0QN_ivMWyMaPCy1VJx_xEeFML%3Duqm50cz6UqFjBTQ%40mail.gmail.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.net

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

Re: [ansible-project] How to debug a community ansible module ?

2020-07-22 Thread Charles Moulliard
That fails if I try what you suggest as the project (I suppose) is no
installed as a collection but git cloned

(.venv)  ~/code/ansible/ansible_collections $
PYTHONPATH=/Users/cmoullia/code/ansible/ansible_collections python3
community/kubernetes/plugins/modules/k8s_log.py
Traceback (most recent call last):
  File "community/kubernetes/plugins/modules/k8s_log.py", line 131, in

from
ansible_collections.community.kubernetes.plugins.module_utils.common import
KubernetesAnsibleModule
ModuleNotFoundError: No module named 'ansible_collections'


On Wed, Jul 22, 2020 at 2:48 PM Abhijeet Kasurde 
wrote:

> Try adding PYTHONPATH
>
> For me it is like
> PYTHONPATH=/Volumes/data/src/ansible/lib:/Volumes/data/src/ansible:/Volumes/data/src/collections
> /Volumes/data/venv3/bin/python 
>
> On Wed, Jul 22, 2020 at 6:10 PM cmou...@redhat.com 
> wrote:
>
>> Hi,
>>
>> As the packages to be imported by a python file are prefixed as
>> "ansible_collections.", how can we then locally debug an Ansible Module
>>
>> Example:
>> https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_log.py
>>
>> from ansible_collections.community.kubernetes.plugins.module_utils.common
>> import KubernetesAnsibleModule
>> ...
>>
>> class KubernetesLogModule(KubernetesAnsibleModule):
>>
>> def __init__(self, *args, **kwargs):
>> KubernetesAnsibleModule.__init__(self, *args,
>>  supports_check_mode=True,
>>  **kwargs)
>>
>> Result
>>
>> /usr/local/bin/python3.7 "/Users/cmoullia/Library/Application
>> Support/JetBrains/IntelliJIdea2020.1/plugins/python/helpers/pydev/pydevd.py"
>> --multiproc --qt-support=auto --client 127.0.0.1 --port 57135 --file
>> /Users/cmoullia/code/ansible/community.kubernetes/plugins/modules/k8s_log.py
>> pydev debugger: process 68087 is connecting
>>
>> Connected to pydev debugger (build 201.8538.31)
>> Traceback (most recent call last):
>>   File "", line 983, in _find_and_load
>>   File "", line 953, in
>> _find_and_load_unlocked
>>   File "", line 219, in
>> _call_with_frames_removed
>> ModuleNotFoundError: No module named 'ansible_collections'
>>
>> Best
>>
>> Charles
>>
>>
>>
>> --
>> 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/386a706d-859f-429b-b100-d3d88ce1d3e8n%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/SlDn22N-1zM/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/CAFwWkHoGSb4T93_UefwDXBKunB_LUzs4TyTjf8pwhLE1H7cjZA%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/CAPb1sSs6x0QN_ivMWyMaPCy1VJx_xEeFML%3Duqm50cz6UqFjBTQ%40mail.gmail.com.


Re: [ansible-project] Need help for install java

2020-07-22 Thread Rajeeb sahoo
Hi

I have a licensed version of rpm. I had converted .rpm to .deb through
alien

I tried with manually but it's not happing.

are you telling me that I should install xz-utils?

I want a specific version like java 8 .deb package.


On Wed, Jul 22, 2020 at 4:39 AM Jean-Yves LENHOF 
wrote:

> Hi,
>
> Where did the package come from ? (sound like alien package of an rpm ?)
>
> Some ideas :
>
> - If the package came from Oracle, very often, an interaction is needed to
> accept EULA...  (I had that kind of problem on CentOS a while ago)
>
> - Have you tried a manual install ?
>
> - Also I saw that xz-utils is needed on remote server (look at
> documentation on apt). Perhaps your playbook should ensure it is installed
> before...
>
> - If you want a specific jdk version not packaged for debian, use *make*-jpkg
> to create a good package that can be installed without prompting user.
>
> Regards,
>
> JYL
>
>
> Le 21/07/2020 à 22:41, Rajeeb sahoo a écrit :
>
> - name: Install java DEB package
>   hosts: ubuntu_test
>   become: yes
>   tasks:
>
> - name: Copy jdk.deb file
>   copy:
> src: /home/centos/jdk1.8_1.8.0231-1_amd64.deb
> dest: /tmp
>
> - name: Installing jdk.deb package
>   apt:
> deb: /tmp/jdk1.8_1.8.0231-1_amd64.deb
> state: present
>
> - name: Copy jre.deb file
>   copy:
> src: /home/centos/jre1.8_1.8.0211-1_amd64.deb
> dest: /tmp
>
> - name: Installing jre.deb package
>   apt:
> deb: /tmp/jre1.8_1.8.0211-1_amd64.deb
> state: present
>
> Ran this. but it's not installing in remote rserver
>
> On Wed, Jul 22, 2020 at 1:55 AM Dick Visser  wrote:
>
>> Best to get started first:
>>
>> https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html
>> Then try this for your first playbook:
>> https://docs.ansible.com/ansible/latest/modules/apt_module.html
>>
>> On Tue, 21 Jul 2020 at 22:05, rajeeb...@scienaptic.com
>>  wrote:
>> >
>> > Hello,
>> > I am new in Ansible.
>> > I need to install ORACLE JAVA 8 and that package is in .deb.
>> (jdk1.8_1.8.0231-1_amd64.deb, jre1.8_1.8.0211-1_amd64.deb)
>> > can anyone help me out to write ansible code for install java with the
>> above condition?
>> >
>> >
>> >
>> > Thanks
>> > Rajeeb
>> >
>> > --
>> > 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/6c4450ad-a133-43ff-80e9-2c7af4b43b3cn%40googlegroups.com
>> .
>>
>>
>>
>> --
>> Dick Visser
>> Trust & Identity Service Operations Manager
>> GÉANT
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwN6fa%3Dg0ogztq1R1PmuhN5PDqz9s01zZXEK149y9Li9Cw%40mail.gmail.com
>> .
>>
>
>
> --
>
> *Thanks & Regards, *
> *Rajeeb Sahoo*
> --
> 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/CAEzMhAYRJmpVqB7870yedTB4aSBDWh%3DH1zZ%2Brj1RWD_JfU0vtg%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/93480ccc-998c-8ea0-a4af-37ef0dd65c2b%40lenhof.eu.org
> 
> .
>


-- 

*Thanks & Regards,*
*Rajeeb Sahoo*

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


Re: [ansible-project] working with file

2020-07-22 Thread steveni...@hotmail.fr
OK ! It works, thanks :)
Le mercredi 22 juillet 2020 à 11:01:06 UTC+2, brae...@gmail.com a écrit :

> On 7/22/20 10:18 AM, steveni...@hotmail.fr wrote:
> > Hi,
> > 
> > I have a json file-> cluster_name.json :
> > ["cluster1","cluster2","cluster3","cluster4"]
> > 
> > And I want to iterate on every cluster name to obtain some informations 
> so I use the module vmware_host_service_info.
> > My playbook is -> vmware.yml :
> > ---
> > - name: test
> >   hosts: localhost
> >   vars_files:
> > - cluster_name.json
> >   tasks:
> > - name: Gather info about all ESXi Host in given Cluster
> >   vmware_host_service_info:
> > validate_certs: no
> > hostname: hostname
> > username: user
> > password: password
> > cluster_name: "{{cluster}}"  <-- HERE I WANT TO ITERATE ON 
> EVERY CLUSTER_NAME IN cluster_name.json
> >   delegate_to: localhost
> > 
>
> Replace vars_files with a lookup:
>
> vars:
> cluster_names: "{{ lookup( 'file', 'cluster_name.json' ) }}"
>
> This automatically converts the file contents from JSON to a list.
>
> You can now loop over that:
>
> tasks:
> - name: Gather info about all ESXi Host in given Cluster
> vmware_host_service_info:
> validate_certs: no
> hostname: hostname
> username: user
> password: password
> cluster_name: "{{ item }}"
> with_items: "{{ cluster_names }}"
> delegate_to: localhost
>
> Regards
> Racke
>
> > 
> > 
> > Le mardi 21 juillet 2020 à 18:57:22 UTC+2, dick@geant.org a écrit :
> > 
> > On Tue, 21 Jul 2020 at 16:08, nicolas stevenin  
> wrote:
> > 
> > Hi,
> > 
> > I have a file like : [1,2,3,4,5] 
> > 
> > 
> > 
> > 'Like' is ambiguous. What is like what?
> > Is the filename like 12345? Is the content a json list of integers? 
> Please try to be precise.
> > 
> > 
> > and I want to use loop for each number in this file on the playbook (I 
> want to use the file, not write keys in
> > the playbook).
> > 
> > 
> > 
> > No idea again what 'writing keys in the playbook' means. So again please 
> be precise. 
> > 
> > 
> > Could you help me please ?
> > 
> > The playbook:  (and i need to loop on "variable_file")
> > - name: Gather info about all ESXi Host in given Cluster
> >   vmware_host_service_info:
> > validate_certs: no
> > hostname: x
> > username: user
> > password: password
> > cluster_name: "{{variable_file}}"
> > 
> > 
> > 
> > A wild guess, if you want to read the contents of a file ? Maybe this is 
> what you want:
> > 
> > https://docs.ansible.com/ansible/latest/plugins/lookup/lines.html
> > 
> > 
> > 
> > 
> > 
> > Thanks for your help
> > 
> > -- 
> > 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/c4322a92-5792-48e6-9973-59cdfd03b9e7o%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/c4322a92-5792-48e6-9973-59cdfd03b9e7o%40googlegroups.com?utm_medium=email_source=footer
> >.
> > 
> > -- 
> > Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to
> > ansible-proje...@googlegroups.com  ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/ansible-project/1ee51582-de55-4e92-bc1e-928f926f9874n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/1ee51582-de55-4e92-bc1e-928f926f9874n%40googlegroups.com?utm_medium=email_source=footer
> >.
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b21973fa-7a36-4fe8-8f2d-41761623c11fn%40googlegroups.com.


Re: [ansible-project] How to debug a community ansible module ?

2020-07-22 Thread Abhijeet Kasurde
Try adding PYTHONPATH

For me it is like
PYTHONPATH=/Volumes/data/src/ansible/lib:/Volumes/data/src/ansible:/Volumes/data/src/collections
/Volumes/data/venv3/bin/python 

On Wed, Jul 22, 2020 at 6:10 PM cmou...@redhat.com 
wrote:

> Hi,
>
> As the packages to be imported by a python file are prefixed as
> "ansible_collections.", how can we then locally debug an Ansible Module
>
> Example:
> https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_log.py
>
> from ansible_collections.community.kubernetes.plugins.module_utils.common
> import KubernetesAnsibleModule
> ...
>
> class KubernetesLogModule(KubernetesAnsibleModule):
>
> def __init__(self, *args, **kwargs):
> KubernetesAnsibleModule.__init__(self, *args,
>  supports_check_mode=True,
>  **kwargs)
>
> Result
>
> /usr/local/bin/python3.7 "/Users/cmoullia/Library/Application
> Support/JetBrains/IntelliJIdea2020.1/plugins/python/helpers/pydev/pydevd.py"
> --multiproc --qt-support=auto --client 127.0.0.1 --port 57135 --file
> /Users/cmoullia/code/ansible/community.kubernetes/plugins/modules/k8s_log.py
> pydev debugger: process 68087 is connecting
>
> Connected to pydev debugger (build 201.8538.31)
> Traceback (most recent call last):
>   File "", line 983, in _find_and_load
>   File "", line 953, in
> _find_and_load_unlocked
>   File "", line 219, in
> _call_with_frames_removed
> ModuleNotFoundError: No module named 'ansible_collections'
>
> Best
>
> Charles
>
>
>
> --
> 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/386a706d-859f-429b-b100-d3d88ce1d3e8n%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/CAFwWkHoGSb4T93_UefwDXBKunB_LUzs4TyTjf8pwhLE1H7cjZA%40mail.gmail.com.


[ansible-project] How to debug a community ansible module ?

2020-07-22 Thread cmou...@redhat.com
Hi,

As the packages to be imported by a python file are prefixed as 
"ansible_collections.", how can we then locally debug an Ansible Module

Example: 
https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_log.py

from ansible_collections.community.kubernetes.plugins.module_utils.common 
import KubernetesAnsibleModule
...

class KubernetesLogModule(KubernetesAnsibleModule):

def __init__(self, *args, **kwargs):
KubernetesAnsibleModule.__init__(self, *args,
 supports_check_mode=True,
 **kwargs)

Result

/usr/local/bin/python3.7 "/Users/cmoullia/Library/Application 
Support/JetBrains/IntelliJIdea2020.1/plugins/python/helpers/pydev/pydevd.py" 
--multiproc --qt-support=auto --client 127.0.0.1 --port 57135 --file 
/Users/cmoullia/code/ansible/community.kubernetes/plugins/modules/k8s_log.py
pydev debugger: process 68087 is connecting

Connected to pydev debugger (build 201.8538.31)
Traceback (most recent call last):
  File "", line 983, in _find_and_load
  File "", line 953, in _find_and_load_unlocked
  File "", line 219, in 
_call_with_frames_removed
ModuleNotFoundError: No module named 'ansible_collections'

Best

Charles



-- 
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/386a706d-859f-429b-b100-d3d88ce1d3e8n%40googlegroups.com.


[ansible-project] Retrieving a value from NetApp cluster, and assign it to a variable in Playbook

2020-07-22 Thread 'vkk...@yahoo.com' via Ansible Project
New to Ansible, and need your help.

I wanted to use a playbook to retrieve a value about a volume upon the 
entered volume name. Then I assign the value to a variable in Ansible. 
Based on the value, conditionally determine what next step is in my 
playbook. 

Can somebody please illustrate how the code should look like? I don't see a 
way that Ansible can interactively "talk" to the storage back and forth. 

-- 
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/d9e73a3c-6709-4740-a652-64bb3b08e52fo%40googlegroups.com.


Re: [ansible-project] Creating users in VCD Unsupported API version

2020-07-22 Thread Abhijeet Kasurde
Hi Nagesh,

Please set this value
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python

On Wed, Jul 22, 2020 at 3:50 AM Nagesh sheregar  wrote:

> Hi Abhijeet,
>
> i have installed python 3.6 but ansible still showing 2.7, how to fix this
> ?
>
> [root@s605141sl7vl402 ansible]# ansible --version
> ansible 2.9.9
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/root/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 2.7.17 (default, Nov 15 2019, 19:24:58) [GCC 4.8.5
> 20150623 (Red Hat 4.8.5-16)]
> [root@s605141sl7vl402 ansible]# rpm -qa | grep python3
> python3-setuptools-39.2.0-10.el7.noarch
> python3-libs-3.6.8-13.el7.x86_64
> python3-3.6.8-13.el7.x86_64
> python3-pip-9.0.3-7.el7_8.noarch
> [root@s605141sl7vl402 ansible]#
>
>
>
> On Tue, Jul 21, 2020 at 7:59 AM Abhijeet Kasurde 
> wrote:
>
>> Hi Nagesh,
>>
>> After digging a bit, I found that these modules are coming from
>> https://github.com/vmware/ansible-module-vcloud-director and are based
>> upon pyvcloud .
>>
>> Pyvcloud works
>> 
>> on Python 3.6 and onwards, you are using Python 2.7. So you need to update
>> to Python3.
>>
>> On Tue, Jul 21, 2020 at 5:36 PM Nagesh sheregar 
>> wrote:
>>
>>> Hi Abhijeeth,
>>>
>>> please find my  below playbook:
>>>
>>> - name: VCD USER creation
>>>   vcd_user:
>>> user: "{{ vcd_username }}"
>>> password: "{{ vcd_password }}"
>>> host: "{{ vcd_host }}"
>>> org: "{{ vcd_org }}"
>>> api_version: "{{ vcd_api_version }}"
>>> verify_ssl_certs: False
>>> username: "test"
>>> userpassword: "Svvs123!"
>>> role_name: "Organization Administrator"
>>> state: "present"
>>>   register: output
>>>
>>> [root@s605141sl7vl402 ~]#  ls -al
>>> /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/ | grep vcd
>>> -rw-r-.  1 root root  10158 Jul 20 22:44 vcd_catalog_item.py
>>> -rw-r-.  1 root root   7783 Jul 20 22:44 vcd_catalog.py
>>> -rw-r-.  1 root root   8162 Jul 20 22:44 vcd_disk.py
>>> -rw-r-.  1 root root  15602 Jul 20 22:44 vcd_external_network.py
>>> -rw-r-.  1 root root   9046 Jul 20 22:44 vcd_org.py
>>> -rw-r-.  1 root root  15797 Jul 20 22:44 vcd_org_vdc.py
>>> -rw-r-.  1 root root   7266 Jul 20 22:44 vcd_roles.py
>>> -rw-r-.  1 root root   9715 Jul 20 22:44 vcd_user.py
>>> -rw-r-.  1 root root  10399 Jul 20 22:44 vcd_vapp_network.py
>>> -rw-r-.  1 root root  16803 Jul 20 22:44 vcd_vapp.py
>>> -rw-r-.  1 root root  10343 Jul 20 22:44 vcd_vapp_vm_disk.py
>>> -rw-r-.  1 root root   9665 Jul 20 22:44 vcd_vapp_vm_nic.py
>>> -rw-r-.  1 root root  17924 Jul 20 22:44 vcd_vapp_vm.py
>>> -rw-r-.  1 root root   6485 Jul 20 22:44 vcd_vapp_vm_snapshot.py
>>> -rw-r-.  1 root root  20621 Jul 20 22:44 vcd_vdc_gateway.py
>>> -rw-r-.  1 root root  17031 Jul 20 22:44 vcd_vdc_network.py
>>> [root@s605141sl7vl402 ~]#
>>>
>>>
>>>
>>> On Tue, Jul 21, 2020 at 12:11 AM Abhijeet Kasurde 
>>> wrote:
>>>
 Hi Nagesh,

 Where is this vcd_user module coming from? Could you please also paste
 playbook?

 On Tue, Jul 21, 2020 at 8:35 AM Nagesh sheregar 
 wrote:

> Hi taem,
>
> did you guys see this error ?
>
> API version is 34
>
> Unsupported API version. Received '{api_version}' but \"\n
> ^\nSyntaxError: invalid
> syntax\n
>
>
>
> TASK [vcd : VCD USER creation]
> **
> task path: /data01/ansible/playbooks/roles/vcd/tasks/main.yml:1
> <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
> <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
> <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
> /root/.ansible/tmp `"&& mkdir
> /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734 && echo
> ansible-tmp-1595300587.72-9132-3554205710734="` echo
> /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734 `" ) &&
> sleep 0'
> Using module file
> /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vcd_user.py
> <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-9052AXoSqK/tmpu50Pg7
> TO
> /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py
> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x
> /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/
> /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py
> && sleep 0'

Re: [ansible-project] working with file

2020-07-22 Thread Stefan Hornburg (Racke)
On 7/22/20 10:18 AM, steveni...@hotmail.fr wrote:
> Hi,
> 
> I have a json file-> cluster_name.json :
> ["cluster1","cluster2","cluster3","cluster4"]
> 
> And I want to iterate on every cluster name to obtain some informations so I 
> use the module vmware_host_service_info.
> My playbook is -> vmware.yml :
> ---
> - name: test
>   hosts: localhost
>   vars_files:
>     - cluster_name.json
>   tasks:
>     - name: Gather info about all ESXi Host in given Cluster
>       vmware_host_service_info:
>         validate_certs: no
>         hostname: hostname
>         username: user
>         password: password
>         cluster_name: "{{cluster}}"      <-- HERE I WANT TO ITERATE ON EVERY 
> CLUSTER_NAME IN cluster_name.json
>       delegate_to: localhost
> 

Replace vars_files with a lookup:

 vars:
cluster_names: "{{ lookup( 'file', 'cluster_name.json' ) }}"

This automatically converts the file contents from JSON to a list.

You can now loop over that:

 tasks:
   - name: Gather info about all ESXi Host in given Cluster
 vmware_host_service_info:
   validate_certs: no
   hostname: hostname
   username: user
   password: password
   cluster_name: "{{ item }}"
 with_items: "{{ cluster_names }}"
 delegate_to: localhost

Regards
Racke

> 
> 
> Le mardi 21 juillet 2020 à 18:57:22 UTC+2, dick@geant.org a écrit :
> 
> On Tue, 21 Jul 2020 at 16:08, nicolas stevenin  
> wrote:
> 
> Hi,
> 
> I have a file like : [1,2,3,4,5] 
> 
> 
> 
> 'Like' is ambiguous. What is like what?
> Is the filename like 12345? Is the content a json list of integers? 
> Please try to be precise.
> 
> 
> and I want to use loop for each number in this file on the playbook 
> (I want to use the file, not write keys in
> the playbook).
> 
> 
> 
> No idea again what 'writing keys in the playbook' means. So again please 
> be precise. 
> 
> 
> Could you help me please ?
> 
> The playbook:  (and i need to loop on "variable_file")
>     - name: Gather info about all ESXi Host in given Cluster
>       vmware_host_service_info:
>         validate_certs: no
>         hostname: x
>         username: user
>         password: password
>         cluster_name: "{{variable_file}}"
> 
> 
> 
> A wild guess, if you want to read the contents of a file ? Maybe this is 
> what you want:
> 
> https://docs.ansible.com/ansible/latest/plugins/lookup/lines.html
> 
> 
> 
> 
> 
> Thanks for your help
> 
> -- 
> 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/c4322a92-5792-48e6-9973-59cdfd03b9e7o%40googlegroups.com
> 
> .
> 
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1ee51582-de55-4e92-bc1e-928f926f9874n%40googlegroups.com
> .


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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/26aef76c-9614-d391-85d7-e252509117e6%40linuxia.de.


Re: [ansible-project] working with file

2020-07-22 Thread steveni...@hotmail.fr
Hi,

I have a json file-> cluster_name.json :
["cluster1","cluster2","cluster3","cluster4"]

And I want to iterate on every cluster name to obtain some informations so 
I use the module vmware_host_service_info.
My playbook is -> vmware.yml :
---
- name: test
  hosts: localhost
  vars_files:
- cluster_name.json
  tasks:
- name: Gather info about all ESXi Host in given Cluster
  vmware_host_service_info:
validate_certs: no
hostname: hostname
username: user
password: password
cluster_name: "{{cluster}}"  <-- HERE I WANT TO ITERATE ON 
EVERY CLUSTER_NAME IN cluster_name.json
  delegate_to: localhost



Le mardi 21 juillet 2020 à 18:57:22 UTC+2, dick@geant.org a écrit :

> On Tue, 21 Jul 2020 at 16:08, nicolas stevenin  
> wrote:
>
>> Hi,
>>
>> I have a file like : [1,2,3,4,5] 
>>
>
>
> 'Like' is ambiguous. What is like what?
> Is the filename like 12345? Is the content a json list of integers? Please 
> try to be precise.
>
>
> and I want to use loop for each number in this file on the playbook (I 
>> want to use the file, not write keys in the playbook).
>>
>
>
> No idea again what 'writing keys in the playbook' means. So again please 
> be precise. 
>
>
> Could you help me please ?
>>
>> The playbook:  (and i need to loop on "variable_file")
>> - name: Gather info about all ESXi Host in given Cluster
>>   vmware_host_service_info:
>> validate_certs: no
>> hostname: x
>> username: user
>> password: password
>> cluster_name: "{{variable_file}}"
>>
>>
>
> A wild guess, if you want to read the contents of a file ? Maybe this is 
> what you want:
>
> https://docs.ansible.com/ansible/latest/plugins/lookup/lines.html
>
>
>
>
>
>> Thanks for your help
>>
>> -- 
>> 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/c4322a92-5792-48e6-9973-59cdfd03b9e7o%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1ee51582-de55-4e92-bc1e-928f926f9874n%40googlegroups.com.


Re: [ansible-project] Ansible Remote Versioning

2020-07-22 Thread Stefan Hornburg (Racke)
On 7/22/20 9:36 AM, Firesh Bakhda wrote:
> Hi JYL,
> 
> This is a great insight you have provided. That would certainly a good way on 
> how to manipulate the Ansible and Ansible
> Tasks on each runs. 
> What what it doesn't solve is that how do i populate that fact file with 
> Tasks that has already been ran. 
> 
> For example,  at the end of each Ansible run, if i could generate a JSON file 
> that would look like: 
> 
> {
>     "Task1":1,
>     "Task2":1
> }
> 
> And on Ansible, I can write "When: {{ ansible_local["Task1"] }} exists and {{ 
> ansible_local["Task1"] }} == 1"
> then skip the task. This is ideal.
> 
> However, to generate the fact.d JSON file, i need a way for to know what 
> tasks have been executed in the first place, 
> and thats something i am figuring out, how can i know within this ansible 
> run, what were the tasks executed ? 
>     

Hello Firesh,

maybe ARA (https://ara.recordsansible.org/) can help you here.

Regards
 Racke

> 
> 
> 
> On Tuesday, July 21, 2020 at 3:03:28 PM UTC+8 jyle...@gmail.com wrote:
> 
> Interesting question.
> 
> A local fact is a way :
> 
> 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#local-facts-facts-d
> 
> At the beginning of your playbook you test is the fact relating to your 
> playbook exist.
> 
> If existing, is the version different from the playbook you use
> 
> Do things differently if the version is x or y
> 
> 
> Generally, this could be avoided using some automated test to not make 
> regression in a future version (molecule
> could be useful here if target is a server)
> 
> Regards,
> 
> JYL
> ||
> 
> 
> Le 21/07/2020 à 08:08, Firesh Bakhda a écrit :
>> Hi ,
>>
>> I would like to post to this group to find out if there is anyway for 
>> ansible to actually stamp the client with 
>> Ansible Deployment or Deployment Stamp on what tasks were ran and when 
>> it was ran, like a VERSION or DEPLOYMENT
>> file that we could deposit to the targets. 
>>
>> For example, 
>>
>> On first deployment the ansible scripts may just have tasks like: 
>>
>>  1. APT UPDATE
>>  2. NTPDATE
>>
>> this then was deployment and stamps on the client like this: 
>>
>>  1. Ansible Deployment 21/07/2020 13.35pm - v1.0
>>  1. Tasks:
>>  1. APT UPDATE 21/072020 13;40pm 
>>  2. NTPDATE 21/072020 13.42pm
>>
>>
>> Then this ansible script was updated to contain 2 more tasks like 
>> the below:
>>
>>  1. APT UPDATE
>>  2. TIMESYNC DAEMON UPDATE
>>  3. NTPDATE
>>  4. PROXY UPDATE
>>
>> And when this was ran again, the target system file gets updated 
>> once it completes with:
>>
>>  1. Ansible Deployment 21/07/2020 13.35pm - v1.0
>>  1. Tasks:
>>  1. APT UPDATE 21/072020 13;40pm 
>>  2. NTPDATE 21/072020 13.42pm
>>  2. Ansible Deployment 21/07/2020 14.00pm - v1.1
>>  1. Tasks:
>>  1. APT UPDATE 21/07/2020 14.01pm
>>  2. TIMESYNC DAEMON UPDATE 21/07/2020 14.03pm
>>  3. NTPDATE 21/07/2020 14.04pm
>>  4. PROXY UPDATE 21/07/2020 14.07pm
>>
>>
>>
>> Something like this, this allows those who are maintaining individual 
>> platforms gets to know if the deployed
>> platform is upto date or not. 
>> This would also help to know if the target system is to the latest 
>> deployment or not. 
>> Or is there any mechanism for 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-proje...@googlegroups.com.
>> To view this discussion on the web visit
>> 
>> https://groups.google.com/d/msgid/ansible-project/977f9bab-9572-40e2-a122-cbbc5295b830o%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/5737250d-e71e-406a-a1e2-aba8a1996079n%40googlegroups.com
> .


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

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

Re: [ansible-project] Ansible Remote Versioning

2020-07-22 Thread Jean-Yves LENHOF

Hi,

I gave you some ideas, I did'nt say this is a good practice to know what 
tasks has been already ran.


When you produce ansible role and playbook, you should ensure that you 
can run it whenever previous state was and if run more than once without 
modification results on server should be the same !


Regards,


Le 22/07/2020 à 09:36, Firesh Bakhda a écrit :

Hi JYL,

This is a great insight you have provided. That would certainly a good 
way on how to manipulate the Ansible and Ansible Tasks on each runs.
What what it doesn't solve is that how do i populate that fact file 
with Tasks that has already been ran.


For example,  at the end of each Ansible run, if i could generate a 
JSON file that would look like:


{
    "Task1":1,
    "Task2":1
}

And on Ansible, I can write "When: {{ ansible_local["Task1"] }} exists 
and {{ ansible_local["Task1"] }} == 1"

then skip the task. This is ideal.

However, to generate the fact.d JSON file, i need a way for to know 
what tasks have been executed in the first place,
and thats something i am figuring out, how can i know within this 
ansible run, what were the tasks executed ?




On Tuesday, July 21, 2020 at 3:03:28 PM UTC+8 jyle...@gmail.com wrote:

Interesting question.

A local fact is a way :


https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#local-facts-facts-d

At the beginning of your playbook you test is the fact relating to
your playbook exist.

If existing, is the version different from the playbook you use

Do things differently if the version is x or y


Generally, this could be avoided using some automated test to not
make regression in a future version (molecule could be useful here
if target is a server)

Regards,

JYL
||


Le 21/07/2020 à 08:08, Firesh Bakhda a écrit :

Hi ,

I would like to post to this group to find out if there is anyway
for ansible to actually stamp the client with
Ansible Deployment or Deployment Stamp on what tasks were ran and
when it was ran, like a VERSION or DEPLOYMENT file that we could
deposit to the targets.

For example,

On first deployment the ansible scripts may just have tasks
like:

 1. APT UPDATE
 2. NTPDATE

this then was deployment and stamps on the client like this:

 1. Ansible Deployment 21/07/2020 13.35pm - v1.0
 1. Tasks:
 1. APT UPDATE 21/072020 13;40pm
 2. NTPDATE 21/072020 13.42pm


Then this ansible script was updated to contain 2 more tasks
like the below:

 1. APT UPDATE
 2. TIMESYNC DAEMON UPDATE
 3. NTPDATE
 4. PROXY UPDATE

And when this was ran again, the target system file gets
updated once it completes with:

 1. Ansible Deployment 21/07/2020 13.35pm - v1.0
 1. Tasks:
 1. APT UPDATE 21/072020 13;40pm
 2. NTPDATE 21/072020 13.42pm
 2. Ansible Deployment 21/07/2020 14.00pm - v1.1
 1. Tasks:
 1. APT UPDATE 21/07/2020 14.01pm
 2. TIMESYNC DAEMON UPDATE 21/07/2020 14.03pm
 3. NTPDATE 21/07/2020 14.04pm
 4. PROXY UPDATE 21/07/2020 14.07pm



Something like this, this allows those who are maintaining
individual platforms gets to know if the deployed platform is
upto date or not.
This would also help to know if the target system is to the
latest deployment or not.
Or is there any mechanism for 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-proje...@googlegroups.com.
To view this discussion on the web visit

https://groups.google.com/d/msgid/ansible-project/977f9bab-9572-40e2-a122-cbbc5295b830o%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/5737250d-e71e-406a-a1e2-aba8a1996079n%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 

Re: [ansible-project] Ansible Remote Versioning

2020-07-22 Thread Firesh Bakhda
Hi JYL,

This is a great insight you have provided. That would certainly a good way 
on how to manipulate the Ansible and Ansible Tasks on each runs. 
What what it doesn't solve is that how do i populate that fact file with 
Tasks that has already been ran. 

For example,  at the end of each Ansible run, if i could generate a JSON 
file that would look like: 

{
"Task1":1,
"Task2":1
}

And on Ansible, I can write "When: {{ ansible_local["Task1"] }} exists and 
{{ ansible_local["Task1"] }} == 1"
then skip the task. This is ideal.

However, to generate the fact.d JSON file, i need a way for to know what 
tasks have been executed in the first place, 
and thats something i am figuring out, how can i know within this ansible 
run, what were the tasks executed ? 




On Tuesday, July 21, 2020 at 3:03:28 PM UTC+8 jyle...@gmail.com wrote:

> Interesting question. 
>
> A local fact is a way : 
>
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#local-facts-facts-d
>
> At the beginning of your playbook you test is the fact relating to your 
> playbook exist.
>
> If existing, is the version different from the playbook you use
>
> Do things differently if the version is x or y
>
>
> Generally, this could be avoided using some automated test to not make 
> regression in a future version (molecule could be useful here if target is 
> a server)
>
> Regards,
>
> JYL
>
> Le 21/07/2020 à 08:08, Firesh Bakhda a écrit :
>
> Hi , 
>
> I would like to post to this group to find out if there is anyway for 
> ansible to actually stamp the client with 
> Ansible Deployment or Deployment Stamp on what tasks were ran and when it 
> was ran, like a VERSION or DEPLOYMENT file that we could deposit to the 
> targets. 
>
> For example, 
>
> On first deployment the ansible scripts may just have tasks like: 
>
>
>1. APT UPDATE 
>   2. NTPDATE 
>
> this then was deployment and stamps on the client like this: 
>
>
>1. Ansible Deployment 21/07/2020 13.35pm - v1.0 
>  1. Tasks: 
> 1. APT UPDATE 21/072020 13;40pm  
> 2. NTPDATE 21/072020 13.42pm 
>  
>
> Then this ansible script was updated to contain 2 more tasks like the 
> below:
>
>
>1. APT UPDATE 
>   2. TIMESYNC DAEMON UPDATE 
>   3. NTPDATE 
>   4. PROXY UPDATE 
>
> And when this was ran again, the target system file gets updated once it 
> completes with:
>
>
>1. Ansible Deployment 21/07/2020 13.35pm - v1.0 
>  1. Tasks: 
> 1. APT UPDATE 21/072020 13;40pm  
> 2. NTPDATE 21/072020 13.42pm 
>  2. Ansible Deployment 21/07/2020 14.00pm - v1.1 
>  1. Tasks: 
> 1. APT UPDATE 21/07/2020 14.01pm 
> 2. TIMESYNC DAEMON UPDATE 21/07/2020 14.03pm 
> 3. NTPDATE 21/07/2020 14.04pm 
> 4. PROXY UPDATE 21/07/2020 14.07pm 
>  
>
>
> Something like this, this allows those who are maintaining individual 
> platforms gets to know if the deployed platform is upto date or not. 
> This would also help to know if the target system is to the latest 
> deployment or not. 
> Or is there any mechanism for 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-proje...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/977f9bab-9572-40e2-a122-cbbc5295b830o%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/5737250d-e71e-406a-a1e2-aba8a1996079n%40googlegroups.com.