[ansible-project] ansible-galaxy newb error

2022-09-10 Thread Andy Bach

Hi,

I am pretty new to Ansible, and followed Learn Linux TV's excellent 
tutorial series.

In which, one of the last things we do is refactor things into different 
roles/tasks.

I am trying to follow the  rvm1-ansible "role" I downloaded using:

ansible-galaxy install rvm.ruby

however, I can see their example code was in "playbook" format, I thought I 
could just extract what I need and put it in my tasks/main.yml for the 
targetted web_server role. Like so:

- name: install rvm using the roles function
  roles:
  - { role: rvm.ruby,
  tags: ruby,
  rvm1_rubies: ['ruby-2.6.6'],
  rvm1_user: 'webuser'
}


However I get an instant parsing crash when I try to run the playbook.

$ ansible-playbook site.yml
ERROR! unexpected parameter type in action: 

The error appears to be in 
'/home/webuser/ansible/homelab/roles/web_servers/tasks/main.yml': line 46, 
column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: install rvm using the roles function
  ^ here

I have been trying to find the missing piece on my own through 
documentation and even reading other ansible-galaxy module install steps to 
see if I am missing something obvious which I don't know about.

Thanks

Andy




-- 
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/6c549e27-7f7a-4197-971a-42d0d5ce494bn%40googlegroups.com.


Re: [ansible-project] Ansible dict date to csv file

2022-09-10 Thread Vladimir Botka
Create the list. Put the below declarations into *vars*

  csv_query: '[].[`Clusters`, key, value[].node, value[].state]'
  csv: "{{ Clusters|dict2items|json_query(csv_query)|
   map('flatten')|map('join', ',')|list }}"

gives

  csv:
  - Clusters,192.168.1.1,node1,up
  - Clusters,192.168.1.2,node2,down
  - Clusters,192.168.1.3,node3,up

Write the file

  - copy:
  dest: /tmp/Clusters.csv
  content: "{{ csv|join('\n') }}"

gives

shell> cat /tmp/Clusters.csv 
Clusters,192.168.1.1,node1,up
Clusters,192.168.1.2,node2,down
Clusters,192.168.1.3,node3,up

-- 
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/20220910200420.1fc88026%40gmail.com.


pgpujfFm96WBf.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Re: Ansible dict date to csv file

2022-09-10 Thread Stefan Hornburg (Racke)

On 10/09/2022 18:44, Sagan wrote:

IF you have your closters has dicts in your variable you can use a loop with 
dict2items and loop around it, as to writing it in your file you can use this 
module
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html


Using lineinfile doesn't make sense when your write the whole file. In this 
case the template module is the better choice.

Regards

 Racke




On Saturday, September 10, 2022 at 5:47:07 PM UTC+2 ahar...@gmail.com wrote:

Hello All,

I'm looking for help on below guery. As  bit new to Anisble I could not 
find solution thought I sent lot of time..

Thank you in advance.

I have data getting through set_fact/ *json_query* using *loop*  for 
multiple clusters as below example.
I have saved date to /*variable*/: *Clusters*
It would be like this when I read variable saved data.

*Clusters*:
192.168.1.1 :
- node: node1
  state: up

192.168.1.2 :
- node: nod2
   state: down

192.168.1.3 :
-node: node3
  state: up

and so on

How do I get this date to csv file like below?

Clusters,192.168.1.1,node1,up
Clusters,192.168.1.2,node2,down
Clusters,192.168.1.3,node3,up

--
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/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/151098b0-98da-c694-4c36-f431d3b5e5ed%40linuxia.de.


[ansible-project] Re: Ansible dict date to csv file

2022-09-10 Thread Sagan
IF you have your closters has dicts in your variable you can use a loop 
with dict2items and loop around it, as to writing it in your file you can 
use this module
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html

On Saturday, September 10, 2022 at 5:47:07 PM UTC+2 ahar...@gmail.com wrote:

> Hello All,
>
> I'm looking for help on below guery. As  bit new to Anisble I could not 
> find solution thought I sent lot of time..
>
> Thank you in advance.
>
> I have data getting through set_fact/ *json_query* using  *loop*  for 
> multiple clusters as below example.
> I have saved date to *variable*: *Clusters*
>  
> It would be like this when I read variable saved data.
>
> *Clusters*:
> 192.168.1.1:
> - node: node1
>   state: up
>
> 192.168.1.2:
> - node: nod2
>state: down
>
> 192.168.1.3:
> -node: node3
>   state: up
>
> and so on
>
> How do I get this date to csv file like below?
>
> Clusters,192.168.1.1,node1,up
> Clusters,192.168.1.2,node2,down
> Clusters,192.168.1.3,node3,up
>

-- 
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/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com.


[ansible-project] Ansible dict date to csv file

2022-09-10 Thread Aharonu
Hello All,

I'm looking for help on below guery. As  bit new to Anisble I could not
find solution thought I sent lot of time..

Thank you in advance.

I have data getting through set_fact/ *json_query* using  *loop*  for
multiple clusters as below example.
I have saved date to *variable*: *Clusters*

It would be like this when I read variable saved data.

*Clusters*:
192.168.1.1:
- node: node1
  state: up

192.168.1.2:
- node: nod2
   state: down

192.168.1.3:
-node: node3
  state: up

and so on

How do I get this date to csv file like below?

Clusters,192.168.1.1,node1,up
Clusters,192.168.1.2,node2,down
Clusters,192.168.1.3,node3,up

-- 
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/CANGEjuXU7E9GQnO0Zp-2N%2BZzGBAKqwrrg%2BzZQ6v3bGq3Jh9JWw%40mail.gmail.com.