Re: [ansible-project] Dynamic Inventories with Openstack

2022-09-19 Thread Dick Visser
On Mon, 19 Sep 2022 at 18:25, Robert Kruck  wrote:

> Hello everyone,
> I am  working on moving our playbooks from ansible 2.9 to 2.12+ and am
> having trouble understanding how to use plugin: openstack.cloud.openstack.
> I am sure it is something simple I am missing or using this wrong so hoping
> someone can point me in the right direction.
>
> I have an openstack.yml file:
>
>
>
> *plugin: openstack.cloud.openstackexpand_hostvars: yesfail_on_errors:
> yesall_projects: yes*
>
> I run the command:
> ansible-inventory -i openstack.yml --list
>
> and get the following error:
>
>
>
>
>
> *[WARNING]:  * Failed to parse
> /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith script plugin:
> problem running /home/rkruck/repos/my-stuff/ansible/openstack.yml --list
> ([Errno 8] Exec format
> error:'/home/rkruck/repos/my-stuff/ansible/openstack.yml')[WARNING]:  *
> Failed to parse /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith auto
> plugin: openstacksdk is required for the OpenStack inventory plugin.*
>

This is a problem. Install that sdk and see if that fixes things



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *OpenStack inventory sources will be skipped.[WARNING]:  * Failed to parse
> /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith yaml plugin: Plugin
> configuration YAML file, not YAML inventory[WARNING]:  * Failed to parse
> /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith ini plugin: Invalid
> host pattern 'plugin:' supplied, ending in ':' is notallowed, this
> character is reserved to provide a port.[WARNING]: Unable to parse
> /home/rkruck/repos/my-stuff/ansible/openstack.yml asan inventory
> source[WARNING]: No inventory was parsed, only implicit localhost is
> available{"_meta": {"hostvars": {}},"all": {
> "children": ["ungrouped"]}}*
>
> I'm sure I am not understanding the proper use of how to use the plugin
> which is why I'm coming to you experts for help :).
>
> v/r
> Robert
>
> --
> 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/75a1d547-9fe3-4464-bbb4-06acd4eb62b2n%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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLb_6CJS9NCKVhKnKHQ-O3CuMra1VZyni7AtxXNueTNU0g%40mail.gmail.com.


[ansible-project] Dynamic Inventories with Openstack

2022-09-19 Thread Robert Kruck
Hello everyone,
I am  working on moving our playbooks from ansible 2.9 to 2.12+ and am 
having trouble understanding how to use plugin: openstack.cloud.openstack.  
I am sure it is something simple I am missing or using this wrong so hoping 
someone can point me in the right direction.

I have an openstack.yml file:



*plugin: openstack.cloud.openstackexpand_hostvars: yesfail_on_errors: 
yesall_projects: yes*

I run the command:
ansible-inventory -i openstack.yml --list

and get the following error:

























*[WARNING]:  * Failed to parse 
/home/rkruck/repos/my-stuff/ansible/openstack.ymlwith script plugin: 
problem running /home/rkruck/repos/my-stuff/ansible/openstack.yml --list 
([Errno 8] Exec format 
error:'/home/rkruck/repos/my-stuff/ansible/openstack.yml')[WARNING]:  * 
Failed to parse /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith auto 
plugin: openstacksdk is required for the OpenStack inventory 
plugin.OpenStack inventory sources will be skipped.[WARNING]:  * Failed to 
parse /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith yaml plugin: 
Plugin configuration YAML file, not YAML inventory[WARNING]:  * Failed to 
parse /home/rkruck/repos/my-stuff/ansible/openstack.ymlwith ini plugin: 
Invalid host pattern 'plugin:' supplied, ending in ':' is notallowed, this 
character is reserved to provide a port.[WARNING]: Unable to parse 
/home/rkruck/repos/my-stuff/ansible/openstack.yml asan inventory 
source[WARNING]: No inventory was parsed, only implicit localhost is 
available{"_meta": {"hostvars": {}},"all": {
"children": ["ungrouped"]}}*

I'm sure I am not understanding the proper use of how to use the plugin 
which is why I'm coming to you experts for help :).

v/r
Robert

-- 
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/75a1d547-9fe3-4464-bbb4-06acd4eb62b2n%40googlegroups.com.


Re: [ansible-project] create variable from value gathered on remote

2022-09-19 Thread dulhaver via Ansible Project


> On 09/19/2022 4:25 PM CEST Todd Lewis  wrote:
> 
> do this:
> 
>loop: "{{ found_files.files | map(attribute='path') | map('basename') | 
> list }}"

great, that works. So one part of the puzzle is solved, thx

-- 
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/1197590870.58407.1663601642760%40office.mailbox.org.


Re: [ansible-project] create variable from value gathered on remote

2022-09-19 Thread Todd Lewis

You're so close. You're passing in a list as a single item. Instead of

  loop:
- "{{ found_files.files | map(attribute='path') | map('basename') | list }}"

do this:

  loop: "{{ found_files.files | map(attribute='path') | map('basename') | list 
}}"




On 9/19/22 10:06 AM, dulhaver via Ansible Project wrote:

I manage to get something like this from a set_fact following the find TASK


TASK [creating a list with the filenames] 
*
task path: 
/home/gwagner/repos/ansible/open_source/postgres_create_service/tasks/fetchsomething.yml:20
ok: [vm-414001-0227.step.zrz.dvz.cn-mv.de] => {
 "ansible_facts": {
 "env_files": [
 "/opt/db/postgres/bin/.pg-service10.env",
 "/opt/db/postgres/bin/.pg-service11.env",
 "/opt/db/postgres/bin/.pg-service12.env",
 "/opt/db/postgres/bin/.pg-service13.env",
 "/opt/db/postgres/bin/.pg-service14.env",
 "/opt/db/postgres/bin/.pg-service15.env",
 "/opt/db/postgres/bin/.pg-service16.env",
 "/opt/db/postgres/bin/.pg-service17.env",
 "/opt/db/postgres/bin/.pg-service18.env"
 ]
 },
 "changed": false
}
***

so, it looks I would be getting closer, but obviousely need to fond a way to 
feed this as single items into a koop pf a fetch TASK. At the moment this is 
bein interpreted as one long string

 "item": [
 ".pg-service10.env",
 ".pg-service11.env",
 ".pg-service12.env",
 ".pg-service13.env",
 ".pg-service14.env",
 ".pg-service15.env",
 ".pg-service16.env",
 ".pg-service17.env",
 ".pg-service18.env"
 ],
 "msg": "the remote file does not exist, not transferring, ignored"

which to no big surprise isn't recognized as what it should by the fetch TASK

here is the entire part of the playbook addressing the fetching
###
---
# TASKS for fetching all .env files from a Postgres DBaaS Machine

- name: finding all .pg-*.env files from the server
   ansible.builtin.find:
 paths: "/opt/db/postgres/bin"
 hidden: true
 recurse: true
 file_type: any
 patterns: '*pg-service1*.env'
   register: found_files
   become: true

- name: creating a list with the filenames
   set_fact:
 env_files: "{{ found_files.files | map(attribute='path') }}"

- name: fetch all .env files into a "fetched" folder on Ansible machine
   ansible.builtin.fetch:
 src: "/opt/db/postgres/bin/{{ item }}"
 dest: fetched/
 flat: true
   become: yes
   loop:
 - "{{ found_files.files | map(attribute='path') | map('basename') | list 
}}"

###


--
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/06300153-31e8-9172-13c3-27cd916ae8f1%40gmail.com.


Re: [ansible-project] create variable from value gathered on remote

2022-09-19 Thread dulhaver via Ansible Project
I manage to get something like this from a set_fact following the find TASK


TASK [creating a list with the filenames] 
*
task path: 
/home/gwagner/repos/ansible/open_source/postgres_create_service/tasks/fetchsomething.yml:20
ok: [vm-414001-0227.step.zrz.dvz.cn-mv.de] => {
"ansible_facts": {
"env_files": [
"/opt/db/postgres/bin/.pg-service10.env",
"/opt/db/postgres/bin/.pg-service11.env",
"/opt/db/postgres/bin/.pg-service12.env",
"/opt/db/postgres/bin/.pg-service13.env",
"/opt/db/postgres/bin/.pg-service14.env",
"/opt/db/postgres/bin/.pg-service15.env",
"/opt/db/postgres/bin/.pg-service16.env",
"/opt/db/postgres/bin/.pg-service17.env",
"/opt/db/postgres/bin/.pg-service18.env"
]
},
"changed": false
}
***

so, it looks I would be getting closer, but obviousely need to fond a way to 
feed this as single items into a koop pf a fetch TASK. At the moment this is 
bein interpreted as one long string

"item": [
".pg-service10.env",
".pg-service11.env",
".pg-service12.env",
".pg-service13.env",
".pg-service14.env",
".pg-service15.env",
".pg-service16.env",
".pg-service17.env",
".pg-service18.env"
],
"msg": "the remote file does not exist, not transferring, ignored"

which to no big surprise isn't recognized as what it should by the fetch TASK

here is the entire part of the playbook addressing the fetching
###
---
# TASKS for fetching all .env files from a Postgres DBaaS Machine

- name: finding all .pg-*.env files from the server
  ansible.builtin.find:
paths: "/opt/db/postgres/bin"
hidden: true
recurse: true
file_type: any
patterns: '*pg-service1*.env'
  register: found_files
  become: true

- name: creating a list with the filenames
  set_fact:
env_files: "{{ found_files.files | map(attribute='path') }}"

- name: fetch all .env files into a "fetched" folder on Ansible machine
  ansible.builtin.fetch:
src: "/opt/db/postgres/bin/{{ item }}"
dest: fetched/
flat: true
  become: yes
  loop:
- "{{ found_files.files | map(attribute='path') | map('basename') | list }}"

###




> On 09/19/2022 12:34 PM CEST Vladimir Botka  wrote:
> 
>  
> On Mon, 19 Sep 2022 12:23:14 +0200 (CEST)
> dulhaver via Ansible Project  wrote:
> 
> > ... does not localize the files I am looking for.
> > 
> >- name: fetch all .env files to fetched
> >  ansible.builtin.fetch:
> >src: /opt/db/postgres/bin/.pg*env
> >dest: fetched/
> >flat: true
> >  become: yes
> 
> Find the files first. See
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/find_module.html
> 
> -- 
> 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/1231326973.49948.1663596397222%40office.mailbox.org.


Re: [ansible-project] Ansible Tower 3.8.6 - Workflow Survey - Updating choices on one question

2022-09-19 Thread glenc2...@comcast.net
Ok Thanks. I will do so.

Regards,

Glen

On Monday, September 19, 2022 at 1:42:37 AM UTC-7 dnmv...@gmail.com wrote:

> Hii
> This is the ansible list.
> Your question might get more response on the dedicated AWX list.
>
>
> On Mon, 19 Sept 2022 at 02:49, glen...@comcast.net  
> wrote:
>
>> Hello all! I have been racking my brain on how to update one field in the 
>> survey spec to one survey question. I'm unable to write the code to 
>> actually get this done while still maintaining the survey flow as is so 
>> when it's executed the questions will stay in the same place every time. Or 
>> I make some overly complex code that I begin to making this much harder 
>> that I think it should be. There are some specific requirements I'm trying 
>> to stick to:
>>
>> 1) Must be native to windows with no python on the windows system. Using 
>> only the win_uri module to send the post.
>> 2) The survey MUST keep the same flow of questions. They cannot be 
>> reordered.
>> 3) Must be written in ansible yaml. No python and no external code
>>
>> Here is the spec:
>>
>> "spec": [
>> {
>> "variable": "computer_ou",
>> "required": true,
>> "question_description": "Select Computer OU",
>> "default": "Select Computer OU",
>> "question_name": "Computer OU",
>> "type": "multiplechoice",
>> "choices": "Updated Stuff!\nSelect Computer OU"  << Option 
>> that needs updating
>> },
>> {
>> "question_description": "dsdsdsdsds",
>> "min": 0,
>> "default": "dsdsdsdsds",
>> "max": 1024,
>> "required": true,
>> "choices": "",
>> "new_question": true,
>> "variable": "dsdsdsdsds",
>> "question_name": "Sddsdsdsds",
>> "type": "text"
>> },
>> {
>> "question_description": "22",
>> "min": 0,
>> "default": "dsdsdsdsdsds",
>> "max": 1024,
>> "required": true,
>> "choices": "",
>> "new_question": true,
>> "variable": "dasasas",
>> "question_name": "Ddeddeee",
>> "type": "text"
>> },
>> {
>> "question_description": "qqqwress",
>> "min": 0,
>> "default": "45454redredewdeswdew",
>> "max": 1024,
>> "required": true,
>> "choices": "",
>> "new_question": true,
>> "variable": "aa",
>> "question_name": "234ewewewewew",
>> "type": "text"
>> }
>> ]
>>
>> The very 1st question "Select Computer OU" choices is what needs updating 
>> and no other data point in the spec. I have written code to split out the 4 
>> survey questions and have been successful in making the change in memory 
>> but putting it all back together and in the correct order was overly 
>> complex and want to go a different direction.
>>
>> And I have tried some of the modules for tower but that of course needs 
>> python the system process the request. And that system does not have python 
>> on it. So I'm basically trying to stick to the win_uri module and try and 
>> use everything that would be considered native that does not require 
>> external modules.
>>
>> If anyone has done this or can at least help progress me thru getting the 
>> data changed in the dictionary it would be helpful. I just wish the survey 
>> spec was keyed...That would make it easier to reference and change.
>>
>> Thanks.
>>
>> Glen
>>
>> -- 
>> 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/6ad2a6c7-d65e-4dce-ba53-32d8961bee01n%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/46ca82ba-b4dc-4aac-bd76-bb0a56941b49n%40googlegroups.com.


Re: [ansible-project] create variable from value gathered on remote

2022-09-19 Thread Vladimir Botka
On Mon, 19 Sep 2022 12:23:14 +0200 (CEST)
dulhaver via Ansible Project  wrote:

> ... does not localize the files I am looking for.
> 
>- name: fetch all .env files to fetched
>  ansible.builtin.fetch:
>src: /opt/db/postgres/bin/.pg*env
>dest: fetched/
>flat: true
>  become: yes

Find the files first. See
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/find_module.html

-- 
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/20220919123422.2b2f5b23%40gmail.com.


pgpCAuNUyeGFc.pgp
Description: OpenPGP digital signature


Re: [ansible-project] create variable from value gathered on remote

2022-09-19 Thread dulhaver via Ansible Project
Thanks Vladimir ... that looks pretty sophisticated (almost out of sight-ish) 
... but could be a nice challenge to even understand what is going on :-)

so far I detected one challenge. Maybe my initial question has not been 
sufficientely explicit with this.

I run this against a single host that has a couple of paralles postgres 
services running.
The pg-somename.env files, defining the port for each instance which I want to 
use to detext the next free port are located in the same folder and the only 
thing I can tell about the filenames is that they follow a pg*.env naming 
pattern.

as far as my experiments with fetch go it is not able to interpret such a 
pattern in the way regular bash (find, cat, less, ..) does. So the TASK below 
does not localize the files I am looking for.

   - name: fetch all .env files to fetched
 ansible.builtin.fetch:
   src: /opt/db/postgres/bin/.pg*env
   dest: fetched/
   flat: true
 become: yes

is there a trick to make this work? A colleague mentioned using the find module 
in order to creating a list for a loop precedding a fetch might be possible. 
But that seems to be pretty hairy as well.





> On 09/16/2022 6:44 PM CEST Vladimir Botka  wrote:
> 
>  
> For example, given the files
> 
> shell> ssh admin@test_11 cat /tmp/.env
> SMTPPORT: 5432
> POPPORT: 5431
> PGPORT: 5433
> 
> shell> ssh admin@test_12 cat /tmp/.env
> SMTPPORT: 4432
> POPPORT: 4431
> PGPORT: 4433
> 
> shell> ssh admin@test_13 cat /tmp/.env
> SMTPPORT: 3432
> POPPORT: 3431
> PGPORT: 3433
> 
> Fetch the files and declare the variables you need
> 
> shell> cat pb.yml
> - hosts: test_11,test_12,test_13
>   vars:
> env_file: /tmp/.env
> env_dest: "{{ playbook_dir }}/env_dest"
> my_env_file: "{{ [env_dest, inventory_hostname, env_file]|
>  join('/') }}"
> my_ports: "{{ lookup('file', my_env_file)|from_yaml }}"
> pg_service_port: "{{ my_ports.PGPORT + 1 }}"
>   tasks:
> - fetch:
> src: "{{ env_file }}"
> dest: "{{ env_dest }}"
> - debug:
> var: pg_service_port
> 
> give (abridged)
> 
> ok: [test_11] => 
>   pg_service_port: '5434'
> ok: [test_12] => 
>   pg_service_port: '4434'
> ok: [test_13] => 
>   pg_service_port: '3434'
> 
> -- 
> 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/20220916184429.2cc0a3a3%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/1493630455.27925.1663582994476%40office.mailbox.org.


Re: [ansible-project] Ansible Tower 3.8.6 - Workflow Survey - Updating choices on one question

2022-09-19 Thread Dick Visser
Hii
This is the ansible list.
Your question might get more response on the dedicated AWX list.


On Mon, 19 Sept 2022 at 02:49, glenc2...@comcast.net 
wrote:

> Hello all! I have been racking my brain on how to update one field in the
> survey spec to one survey question. I'm unable to write the code to
> actually get this done while still maintaining the survey flow as is so
> when it's executed the questions will stay in the same place every time. Or
> I make some overly complex code that I begin to making this much harder
> that I think it should be. There are some specific requirements I'm trying
> to stick to:
>
> 1) Must be native to windows with no python on the windows system. Using
> only the win_uri module to send the post.
> 2) The survey MUST keep the same flow of questions. They cannot be
> reordered.
> 3) Must be written in ansible yaml. No python and no external code
>
> Here is the spec:
>
> "spec": [
> {
> "variable": "computer_ou",
> "required": true,
> "question_description": "Select Computer OU",
> "default": "Select Computer OU",
> "question_name": "Computer OU",
> "type": "multiplechoice",
> "choices": "Updated Stuff!\nSelect Computer OU"  << Option
> that needs updating
> },
> {
> "question_description": "dsdsdsdsds",
> "min": 0,
> "default": "dsdsdsdsds",
> "max": 1024,
> "required": true,
> "choices": "",
> "new_question": true,
> "variable": "dsdsdsdsds",
> "question_name": "Sddsdsdsds",
> "type": "text"
> },
> {
> "question_description": "22",
> "min": 0,
> "default": "dsdsdsdsdsds",
> "max": 1024,
> "required": true,
> "choices": "",
> "new_question": true,
> "variable": "dasasas",
> "question_name": "Ddeddeee",
> "type": "text"
> },
> {
> "question_description": "qqqwress",
> "min": 0,
> "default": "45454redredewdeswdew",
> "max": 1024,
> "required": true,
> "choices": "",
> "new_question": true,
> "variable": "aa",
> "question_name": "234ewewewewew",
> "type": "text"
> }
> ]
>
> The very 1st question "Select Computer OU" choices is what needs updating
> and no other data point in the spec. I have written code to split out the 4
> survey questions and have been successful in making the change in memory
> but putting it all back together and in the correct order was overly
> complex and want to go a different direction.
>
> And I have tried some of the modules for tower but that of course needs
> python the system process the request. And that system does not have python
> on it. So I'm basically trying to stick to the win_uri module and try and
> use everything that would be considered native that does not require
> external modules.
>
> If anyone has done this or can at least help progress me thru getting the
> data changed in the dictionary it would be helpful. I just wish the survey
> spec was keyed...That would make it easier to reference and change.
>
> Thanks.
>
> Glen
>
> --
> 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/6ad2a6c7-d65e-4dce-ba53-32d8961bee01n%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/CAF8BbLYjyZXX7LcmCh6%3D3PO3DYPR9AoBzM0e62rsm1n-EFxFDA%40mail.gmail.com.