Hi
I'm trying to do the following (in windows but it's not important):

   1. Need to deploy N number of build agents to a server (according to the 
   inventory nb_of_agents)  - *iteration1*
   2. Each agent should have a unique port starting from 8811 - *iteration2*
   3. Check if the service is already present - store in register. - *REGISTER 
   LIST*
   4. Install according to the register.

First question: Using a register list, how do i use : when: 
service.results.exists for specific index? 
Second question: how do i go in parrallel via multiple list:

   1. with_sequence: start=1 end='{{ nb_of_agents}}'' *and*
   2. with_sequence: start=8811 count='{{ nb_of_agents}}'' *and*
   3. when: service.result[index].exists


So the code looks like this:
- name: check service '{{ item }}' is not already running
win_service:
name: Build Agent Prod '{{ item }}'
register: svc
with_sequence: start=1 end='{{nb_of_agents}}'

- name: output
debug:
var: svc
- name: output
debug:
var: svc.results.[item].exists
with_sequence: count='{{nb_of_agents}}'

- name: install Agent '{{ item }}'
win_copy: 
src: \\some\share\buildagent_prod_template
dest: 'D:\buildagent_prod_{{ item }}'
force: no
remote_src: yes
when: svc.results[item].exists == false
register: agent
with_sequence: count='{{nb_of_agents}}'
- name: modify Port
win_lineinfile:
path: D:\buildagent_prod_{{ item }}\conf\node.properties
backrefs: yes
regexp: '(^port)=.*'
line: '$1={{ item2 }}'
when: 'agent.results[item]'
with_together: count=nb_of_agents
with_items: start=qb_prod_agent_port count=nb_of_agents


*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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/babac43c-57f2-4091-b2ee-8fdc32291378%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to