Hi , 

Im a newbie learnig ansible .im stuck with the below 


*I need to get input from user and based on input  dynamically create a url 
.*

*input group1 is a single value and  group2 is a list *

*using  with_items and loop im able to create variable but couldnt register 
it and  pass it to get_url module . below is one of my failed attempts .*

*ansible-playbook -e "app_name=group1 or app_name=group2 ...."*

*---*
*- name: Block to Deploy on Servers*
*  block:*
*        - set_fact:*
*      artifact_url: "https://my.url"*
*        - set_fact:*

*             group_id: "{% if app_name == 'group1' %}/com/connectors/{% 
elif app_name == 'group2' %}*
*             /com/connectors/{% else %}/com/services/{% endif %}"*
*             register: group_id *
 
*    - set_fact:*
*            artifacturl: "{ artifact_url }}{{ group_id }}{{ item }}/{{ 
app_version }}/{{ item }}-{{ app_version }}.jar"*
* when: app_name == group2*
* loop:*
*    - jar1*
*    - jar2 *
* register: artifacturl*
*    - set_fact:*
*            artifacturl: "{ artifact_url }}{{ group_id }}{{ app_name }}/{{ 
app_version }}/{{ app_name }}-{{ app_version }}.jar"*
*            when: app_name != group2*

*pass the constructed variable to another block *

*- name: Block to get file "{{app_name}}"*
*  block:*
*        - name: download "{{app_name}}" form url*
*          get_url:*
*            url:  "{{ artifacturl }}"*
*            dest: "/manual/{{ app_name }}.jar"*
*   loop:*
*      - {{ artifacturl }}*

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/688960f5-68f1-4280-8da6-fe909facef51n%40googlegroups.com.

Reply via email to