Hi David
Here it is:

    - 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

On Monday, May 21, 2018 at 5:05:57 PM UTC+3, David Villasmil wrote:
>
> Please paste the code WITHOUT any formatting. Font should be any 
> single-space so that spacing is correct.
>
> On Mon, May 21, 2018, 15:55 Jeremie Levy <jer...@gmail.com <javascript:>> 
> wrote:
>
>> 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-proje...@googlegroups.com <javascript:>.
>> To post to this group, send email to ansible...@googlegroups.com 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/babac43c-57f2-4091-b2ee-8fdc32291378%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/babac43c-57f2-4091-b2ee-8fdc32291378%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/772fc9fb-4681-46e8-96eb-691998ebfb78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to