[ansible-project] Re: Some user of ansible_user

2019-08-20 Thread Zolvaring
Ah I missed your detail about serial usage, but am not sure how you could do 
that. You could import or include a play with some sort of loop, or maybe 
registering a var after the final task and setting ansible_ssh_user to that var 
if it exists prior to the first task?

-- 
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/792af329-9104-4b15-b946-1e3cce4d8992%40googlegroups.com.


[ansible-project] Re: Some user of ansible_user

2019-08-20 Thread Zolvaring
I'm confused what you want to do when you use a second user. If you want 
fallback users, I don't know of a simple built in way but have gotten it to 
work looping user/pass /key combos with gather facts or a shell "sudo -l" 
command and register. Then loop through your registered var with set_facts and 
it's possible to set for each host the first successful credential set that 
worked before continuing the play.

If you want different tasks to be run with different users you can use become 
and become_user.

-- 
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/8bc9d204-e6be-4a84-893c-4960f519bcea%40googlegroups.com.


[ansible-project] Re: Some user of ansible_user

2019-08-20 Thread Karther
hey,

Help please Community Ansible  ;)

Regards,

Le mardi 20 août 2019 17:00:33 UTC+2, Karther a écrit :
>
> Hey,
>
> I want to know if possible use a lot of user for ansible.
>
> Exemple, if i use *ansible_user=user1, user2*
>
> because i want to use *serial: 1* 
>
> And i want that ansible use firt user1 and secondaly user2
>
> If possible or not please ??
>
> Regards,
>

-- 
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/fdfa271f-664b-48c5-8e6d-342f26c42e61%40googlegroups.com.


Re: [ansible-project] Need Help!!!!

2019-08-20 Thread Jyotsna Mehta
Hello Jonathan,

I am new at this -- This is what I have created so far

---
- name: Restart a service
  win_service:
name: LoadRunnerAgent
state: restarted
username: domain\user
password: pwd



On Tuesday, August 20, 2019 at 3:33:37 PM UTC-4, Jonathan Lozada De La 
Matta wrote:
>
> Jyotsna,
>
> Can you share what you have so far?
>
> On Tue, Aug 20, 2019 at 3:32 PM Jyotsna Mehta  > wrote:
>
>> Can someone help me create a playbook that restarts windows based load 
>> runner service on multiple windows servers?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/97af4b82-1033-48cd-bffd-ccf242f0bae3%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
>
> Jonathan Cha'gara Lozada De La Matta 
>
> He / Him / His
>
> Red Hat  
>
> Senior Automation Practice Consultant & Automation CoP Manager
>
> Join the Automation CoP! https://red.ht/autocop
> @redhatjobs    redhatjobs 
>  @redhatjobs 
>    
>  
>  
>
>

-- 
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/8874816b-b84d-4da6-95b1-e58b629eeb6a%40googlegroups.com.


[ansible-project] yum history

2019-08-20 Thread Amos
So, in bash I can get some info from 'yum history'.

Get the last 'yum update':

yum history | grep Update | head -1

Get the very last call to yum:

yum history | awk '/^/{ n=NR+1 }n && n<=NR && NR<(n+1){ print }'

How do I parse that with an ansible regex?

-- 
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/CAK2viQV1x670%3DyF7LvvkhkGnSZ2svXFX3EVVPXHfnG-sM21ToQ%40mail.gmail.com.


Re: [ansible-project] Need Help!!!!

2019-08-20 Thread Jonathan Lozada De La Matta
Jyotsna,

Can you share what you have so far?

On Tue, Aug 20, 2019 at 3:32 PM Jyotsna Mehta 
wrote:

> Can someone help me create a playbook that restarts windows based load
> runner service on multiple windows servers?
>
> --
> 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/97af4b82-1033-48cd-bffd-ccf242f0bae3%40googlegroups.com
> 
> .
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2BK0VvBHU2pLs6Oa87HXSnjqsfO-zOKpmPpoR5f%3DY3vW_Q%40mail.gmail.com.


[ansible-project] Need Help!!!!

2019-08-20 Thread Jyotsna Mehta
Can someone help me create a playbook that restarts windows based load 
runner service on multiple windows servers?

-- 
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/97af4b82-1033-48cd-bffd-ccf242f0bae3%40googlegroups.com.


Re: [ansible-project] Ansible and Satellite 6.4 - Waiting for Promote To Finish

2019-08-20 Thread Jonathan Lozada De La Matta
Cade,

Check out
https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html
There's delays, retries etc. You can use any of this to accomplish what you
want.

On Tue, Aug 20, 2019 at 1:29 PM Cade Lambert  wrote:

> I created a playbook to connect to Satellite via API, publish new content
> views, and promote the various lifecycle environments to these new Content
> View versions, looping through a list of Lifecycle Environments.  The issue
> I'm having is I can't figure out a way for my task to wait until the
> promotion of one Lifecycle Environment is completed before attempting to
> promote the next.  If it tries to promote while a promotion is already in
> progress, the task fails.  I've added a delay to the task to try to wait it
> out but that doesn't always work and was hoping for a more clever
> solution.  Here's my task:
>
>   - name: Promote new RHEL7 version to Lifecycle Environments
> uri:
>   url: "
> https://satelliteserver/katello/api/v2/content_view_versions/{{
> (content_views7.json.results[0].id | int) }}/promote"
>   method: POST
>   body:
> description: "Promoted by Tower"
> environment_id: "{{ item }}"
> organization_id: 3
> force: true
>   user: "{{ satellite_user }}"
>   password: "{{ satellite_pass }}"
>   force_basic_auth: yes
>   validate_certs: no
>   body_format: json
>   status_code: 202
> loop:
>   - 3
>   - 4
>   - 5
>   - 6
>   - 7
>   - 8
> loop_control:
>   pause: 180
>
> Any input on a way to wait for the promotion to finish, or a cleaner way
> of doing the same thing?
>
> --
> 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/60b7d8f5-fad5-47c6-bb22-91c47ae0da1c%40googlegroups.com
> 
> .
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2BLcJ--_481%3DbLW4krdNob8h2-bpTLio%3D%3DGsJzh7jaq_FQ%40mail.gmail.com.


[ansible-project] Ansible and Satellite 6.4 - Waiting for Promote To Finish

2019-08-20 Thread Cade Lambert
I created a playbook to connect to Satellite via API, publish new content 
views, and promote the various lifecycle environments to these new Content 
View versions, looping through a list of Lifecycle Environments.  The issue 
I'm having is I can't figure out a way for my task to wait until the 
promotion of one Lifecycle Environment is completed before attempting to 
promote the next.  If it tries to promote while a promotion is already in 
progress, the task fails.  I've added a delay to the task to try to wait it 
out but that doesn't always work and was hoping for a more clever 
solution.  Here's my task:

  - name: Promote new RHEL7 version to Lifecycle Environments
uri:
  url: "https://satelliteserver/katello/api/v2/content_view_versions/{{ 
(content_views7.json.results[0].id | int) }}/promote"
  method: POST
  body:
description: "Promoted by Tower"
environment_id: "{{ item }}"
organization_id: 3
force: true
  user: "{{ satellite_user }}"
  password: "{{ satellite_pass }}"
  force_basic_auth: yes
  validate_certs: no
  body_format: json
  status_code: 202
loop:
  - 3
  - 4
  - 5
  - 6
  - 7
  - 8
loop_control:
  pause: 180

Any input on a way to wait for the promotion to finish, or a cleaner way of 
doing the same thing?

-- 
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/60b7d8f5-fad5-47c6-bb22-91c47ae0da1c%40googlegroups.com.


[ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Zolvaring
I think what you're looking for is the 'delegate_to' task parameter. If you 
wanted the local action to only run once you can combine this with the 
'run_once' task parameter -- for your example
- name: bring file locally
  command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}"
  delegate_to: localhost
  run_once: true

On Tuesday, August 20, 2019 at 6:41:38 AM UTC-7, Mike Eggleston wrote:
>
> I'm working on a playbook to deploy an internal application to internal 
> hosts. This application is delivered by development to QA in a *.tar.gz 
> file. The file is staged and deployed to QA (by me) in that *.tar.gz file. 
> What I would like/am thinking of is something like:
>
> $ ansible-playbook remote-group -k -e 
> '{"qahost":"qaserver","version":2.75.26.1","path":"/home/app/app_2.75.26.1.tar.gz"}'
>
> and the playbook would be something like:
>
> ---
> - hosts: v2app
>   gather_facts: yes
>
>   vars:
> qahost: "{{ qahost }}"
> version: "{{ version }}"
> remotepath: "{{ path }}"
> localpath: "/tmp/{{version}}.tar.gz"
>
>   tasks:
> - name: bring file locally
>   command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}"
>   local: true
>
> # localpath referes to /tmp, so using it twice means once on the local 
> server and once on the remote app server
> - name: copy the deployment file from QA locally
>   copy:src={{localpath}} dest={{localpath}}
>
> - name: extract the deployment file on the app server
>   command: tar -xzf {{localpath}}
>
> # still testing, so using /tmp for all updates
> - name: make a copy of the application
>   shell: rm -rf /tmp/app ; cp -r -p /opt/app /tmp
>
> - name: sync the new files to the application
>   shell: cd /tmp/app; rsync -a {{localpath}} .
>
> - name: clean up
>   command: rm -f {{localpath}}
>
> (I'm just typing from memory and haven't syntax checked the above.)
>
> How can I execute a single task of a playbook on the local server and the 
> rest of the tasks on the remote servers? (Is this even possible?)
>
> TIA
>
> Mike
>

-- 
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/922ad671-28d8-4c47-b39a-b9cf0177d39f%40googlegroups.com.


[ansible-project] rksh does not allow me to run /bin/sh -c so ansible failes

2019-08-20 Thread Tom Van de Velde
Hi,

I want to use Ansible to a target using an ssh connection and a restricted 
shell

I have setup   gather_facts: false in my playbook, but even then Ansible is 
trying to guess the discovered_interpreter_python and returns an error 
because this is not allowed in the restricted shell.

 Attempting python interpreter discovery
 ESTABLISH SSH CONNECTION FOR USER: secadmin
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s 
-o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="padmin"' -o ConnectTimeout=10 -o 
ControlPath=/home/user/.ansible/cp/7c17f9a5a6 sec_system '/bin/sh -c 
'"'"'echo PLATFORM; uname; echo FOUND; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.5'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''
 (1, b'', b'rksh: /bin/sh: 0403-019 The operation is not 
allowed in a restricted shell.\n')
 Failed to connect to the host via ssh: rksh: /bin/sh: 0403-019 
The operation is not allowed in a restricted shell.

So infact  ansible is trying to /bin/sh -c into the system and this is not 
allowed

Does anybody know how to prevent this check so I can use the raw command ?

Regards,
Tom


ansible --version
ansible 2.8.0
  config file = /home/user/git/ansible_project/etc/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Apr 25 2019, 21:02:35) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-36)]

-- 
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/679ca2b4-f2da-499f-a50b-cb09847cd89c%40googlegroups.com.


Re: [ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Karl Auer
Haven't checked this, but I think you can have multiple sections in a
playbook with different hosts. Maybe not.

Try
- hosts: localhost
   ...

- hosts: something_else
   ...

I assume (always dangerous) that if it works at all the hosts sections
would be processed in order, so you could rely on the localhost stuff
happening first.

Regards, K.


On Wed, Aug 21, 2019 at 12:41 AM Mike Eggleston 
wrote:

> That's a great idea. Thank you.
>
> Mike
>
> --
> 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/40b509a6-3f65-4060-8c2f-e06e59064163%40googlegroups.com
> 
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
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/CA%2B%2BT08SwJRvKTjcgmgZV31%2Bryok4CqpPJnR0EZtzHvH1gnrUJA%40mail.gmail.com.


[ansible-project] Some user of ansible_user

2019-08-20 Thread Karther
Hey,

I want to know if possible use a lot of user for ansible.

Exemple, if i use *ansible_user=user1, user2*

because i want to use *serial: 1* 

And i want that ansible use firt user1 and secondaly user2

If possible or not please ??

Regards,

-- 
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/6ca7c384-bf8c-4f4c-99d5-6cc943b9516f%40googlegroups.com.


[ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Mike Eggleston
That's a great idea. Thank you.

Mike

-- 
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/40b509a6-3f65-4060-8c2f-e06e59064163%40googlegroups.com.


[ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Auralan
Hi,

One way to do this is to append your tasks with a when statement 

 in 
conjunction the special variables 

 inventory_hostname and group_names.

Something like this should work for you:

- name: "this only runs on localhost"
shell: /foo
when: (inventory_hostname == 'localhost')

- name: "this runs on every host in the servers group"
shell: /bar
when: ('servers' in group_names)



On Tuesday, 20 August 2019 15:41:38 UTC+2, Mike Eggleston wrote:
>
> I'm working on a playbook to deploy an internal application to internal 
> hosts. This application is delivered by development to QA in a *.tar.gz 
> file. The file is staged and deployed to QA (by me) in that *.tar.gz file. 
> What I would like/am thinking of is something like:
>
> $ ansible-playbook remote-group -k -e 
> '{"qahost":"qaserver","version":2.75.26.1","path":"/home/app/app_2.75.26.1.tar.gz"}'
>
> and the playbook would be something like:
>
> ---
> - hosts: v2app
>   gather_facts: yes
>
>   vars:
> qahost: "{{ qahost }}"
> version: "{{ version }}"
> remotepath: "{{ path }}"
> localpath: "/tmp/{{version}}.tar.gz"
>
>   tasks:
> - name: bring file locally
>   command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}"
>   local: true
>
> # localpath referes to /tmp, so using it twice means once on the local 
> server and once on the remote app server
> - name: copy the deployment file from QA locally
>   copy:src={{localpath}} dest={{localpath}}
>
> - name: extract the deployment file on the app server
>   command: tar -xzf {{localpath}}
>
> # still testing, so using /tmp for all updates
> - name: make a copy of the application
>   shell: rm -rf /tmp/app ; cp -r -p /opt/app /tmp
>
> - name: sync the new files to the application
>   shell: cd /tmp/app; rsync -a {{localpath}} .
>
> - name: clean up
>   command: rm -f {{localpath}}
>
> (I'm just typing from memory and haven't syntax checked the above.)
>
> How can I execute a single task of a playbook on the local server and the 
> rest of the tasks on the remote servers? (Is this even possible?)
>
> TIA
>
> Mike
>

-- 
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/a82dab25-046b-41e0-b2b2-1d6f068252b6%40googlegroups.com.


Re: [ansible-project] Problem with get indice in file

2019-08-20 Thread Karther
Hey,

Help me please !!! :)

If i change this task with lookup, i will be to change my whole program !!! 
;(

Regards,

Le mardi 20 août 2019 15:49:47 UTC+2, Karther a écrit :
>
> Hey,
>
> This module not work !! :/
>
> I have error synthax i don't understand why !! :/
>
> Can you help me for my first message please with this task :
>
> - set_fact:
>   indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}"
>   with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
>   when: item.split(',')[2] == inventory_hostname
>   delegate_to: localhost
>
> Thanks you very much Community Ansible !!! :)
>
> Regards,
>
> Le mardi 20 août 2019 15:29:55 UTC+2, Dick Visser a écrit :
>>
>> Hi 
>>
>>
>>
>> On Tue, 20 Aug 2019 at 14:39, Karther  wrote: 
>> > - set_fact: 
>> >   indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}" 
>> >   with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv 
>> >   when: item.split(',')[2] == inventory_hostname 
>>
>> Stop doing that. 
>> There is a dedicated module to handle csv files: 
>>
>> https://docs.ansible.com/ansible/latest/modules/read_csv_module.html 
>>
>>
>>
>> -- 
>> 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/1a08474b-b5d9-4780-86f9-474dc444df69%40googlegroups.com.


[ansible-project] Re: best practices re ansible-playbook inventories and group_vars

2019-08-20 Thread Jim Robinson
A coworker sent me this thread:

https://stackoverflow.com/questions/40606890/how-to-share-group-vars-between-different-inventories-in-ansible

I like the description from ceving (direct link: 
https://stackoverflow.com/a/47798704)

-- 
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/c61e8485-1f70-47af-9aba-cc60c3bfe449%40googlegroups.com.


Re: [ansible-project] Problem with get indice in file

2019-08-20 Thread Karther
Hey,

This module not work !! :/

I have error synthax i don't understand why !! :/

Can you help me for my first message please with this task :

- set_fact:
  indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}"
  with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
  when: item.split(',')[2] == inventory_hostname
  delegate_to: localhost

Thanks you very much Community Ansible !!! :)

Regards,

Le mardi 20 août 2019 15:29:55 UTC+2, Dick Visser a écrit :
>
> Hi 
>
>
>
> On Tue, 20 Aug 2019 at 14:39, Karther > 
> wrote: 
> > - set_fact: 
> >   indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}" 
> >   with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv 
> >   when: item.split(',')[2] == inventory_hostname 
>
> Stop doing that. 
> There is a dedicated module to handle csv files: 
>
> https://docs.ansible.com/ansible/latest/modules/read_csv_module.html 
>
>
>
> -- 
> 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/3cbd7e43-97c5-4aba-8f2c-dae805227743%40googlegroups.com.


[ansible-project] execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Mike Eggleston
I'm working on a playbook to deploy an internal application to internal 
hosts. This application is delivered by development to QA in a *.tar.gz 
file. The file is staged and deployed to QA (by me) in that *.tar.gz file. 
What I would like/am thinking of is something like:

$ ansible-playbook remote-group -k -e 
'{"qahost":"qaserver","version":2.75.26.1","path":"/home/app/app_2.75.26.1.tar.gz"}'

and the playbook would be something like:

---
- hosts: v2app
  gather_facts: yes

  vars:
qahost: "{{ qahost }}"
version: "{{ version }}"
remotepath: "{{ path }}"
localpath: "/tmp/{{version}}.tar.gz"

  tasks:
- name: bring file locally
  command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}"
  local: true

# localpath referes to /tmp, so using it twice means once on the local 
server and once on the remote app server
- name: copy the deployment file from QA locally
  copy:src={{localpath}} dest={{localpath}}

- name: extract the deployment file on the app server
  command: tar -xzf {{localpath}}

# still testing, so using /tmp for all updates
- name: make a copy of the application
  shell: rm -rf /tmp/app ; cp -r -p /opt/app /tmp

- name: sync the new files to the application
  shell: cd /tmp/app; rsync -a {{localpath}} .

- name: clean up
  command: rm -f {{localpath}}

(I'm just typing from memory and haven't syntax checked the above.)

How can I execute a single task of a playbook on the local server and the 
rest of the tasks on the remote servers? (Is this even possible?)

TIA

Mike

-- 
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/527d31ec-10a7-4617-8b9c-a300483c1c71%40googlegroups.com.


Re: [ansible-project] Problem with get indice in file

2019-08-20 Thread Dick Visser
Hi



On Tue, 20 Aug 2019 at 14:39, Karther  wrote:
> - set_fact:
>   indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}"
>   with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
>   when: item.split(',')[2] == inventory_hostname

Stop doing that.
There is a dedicated module to handle csv files:

https://docs.ansible.com/ansible/latest/modules/read_csv_module.html



-- 
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/CAL8fbwMt7rti%3D-41M2KyCnudCW5fY2DLW46pM_Kvva0PvrZqeA%40mail.gmail.com.


[ansible-project] Re: Problem with get indice in file

2019-08-20 Thread Karther
Hey,

Update.

The problem is that when i use number with same caractere exemple "11, 22, 
33, 44, 55 , etc ..."
This task get only the first caracter "1 or 2 or 3 or 4 , etc..."

Thanks,
Regards,

Le mardi 20 août 2019 14:39:45 UTC+2, Karther a écrit :
>
> Hey !
>
> I have strange problem :
>
> I have on file "clef_applicatives.csv" with this content :
>
> 2,user1,host1,clef1
> 7,user3,host2,clef5
> 6,user4,host4,clef6
> 42,user5,host5,clef7
> 23,user6,host8,clef8
> 3,user7,host3,clef9
> 22,user8,host10,clef14
> 20,user9,host7,clef11
>
> I have on task who get indice depending on the host.
>
> - set_fact:
>   indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}"
>   with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
>   when: item.split(',')[2] == inventory_hostname
>   delegate_to: localhost
>
> My problem is that this task works perfectly but when i use indice "22" in 
> my file "clef_applicatives.csv", my variable indice get only 2 and not 22 
> same if my host is my inventory_hostname 
>
> Someone can help me please ??? :)
>
> I'm desesper !!!
>
> Thanks community ansible  :)
>
> Regards,
>

-- 
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/6f583df1-2a3f-4df5-85ad-7c09cc9fd58c%40googlegroups.com.


[ansible-project] Problem with get indice in file

2019-08-20 Thread Karther
Hey !

I have strange problem :

I have on file "clef_applicatives.csv" with this content :

2,user1,host1,clef1
7,user3,host2,clef5
6,user4,host4,clef6
42,user5,host5,clef7
23,user6,host8,clef8
3,user7,host3,clef9
22,user8,host10,clef14
20,user9,host7,clef11

I have on task who get indice depending on the host.

- set_fact:
  indice: "{{ indice|default([])|union(item.split(',')[0]|list) }}"
  with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
  when: item.split(',')[2] == inventory_hostname
  delegate_to: localhost

My problem is that this task works perfectly but when i use indice "22" in 
my file "clef_applicatives.csv", my variable indice get only 2 and not 22 
same if my host is my inventory_hostname 

Someone can help me please ??? :)

I'm desesper !!!

Thanks community ansible  :)

Regards,

-- 
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/cac462b3-2776-48ed-bcf4-14b4f58c0aff%40googlegroups.com.


Re: [ansible-project] Re: win_dsc UrlAcl and passing int[]

2019-08-20 Thread 'Richard Payne' via Ansible Project
You were right Jordan.

I have to say, I really dislike the use of quotes here.  It is really not 
intuitive what data you are passing.

Thanks for everyone's help.

On Monday, 12 August 2019 08:11:29 UTC+1, Richard Payne wrote:
>
> I thought so, but will try again to confirm.
>
> On Friday, 9 August 2019 21:03:03 UTC+1, Jordan Borean wrote:
>>
>> No you are not, the jinja2 block is evaluated before it’s passed to the 
>> module so the data will contain the array you are looking for. Did you try 
>> it out?
>
>

-- 
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/2f07d9c4-fb7b-45a8-8f5d-4857177d834b%40googlegroups.com.