Adding if statement inside a task

23 views
Skip to first unread message

dudu.c...@gmail.com

unread,
Feb 7, 2022, 9:29:37 AM2/7/22
to Ansible Project
Hi
I have the following playbook.  
In the environment.yml file I have a parameter "tls=true"

In the below task , In tghe URL I would put https if tls=true and http if false.
 
- hosts: manager
  vars_files:
    - ./environment.yml
  tasks:

 - name: test - check connectivity to  API
    get_url:
        url: http://{{ server.hostname }}.{{ domain }}:9999/api//{{ cluster_name }}
        dest: /tmp/
        mode: 0777
        force: yes
        url_username: "{{ username }}"
        url_password: "{{ password }}"
        validate_certs: no
    register: msg
    ignore_errors: true

Thanks 

Rilindo Foster

unread,
Feb 7, 2022, 9:36:52 AM2/7/22
to ansible...@googlegroups.com
Hi there!

What was the problem that you are trying to solve? I don’t see an actual question that we can answer.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d87db8f5-2d22-4d65-8d16-efa6a3041012n%40googlegroups.com.

Dick Visser

unread,
Feb 7, 2022, 9:44:24 AM2/7/22
to ansible...@googlegroups.com
On Mon, 7 Feb 2022 at 15:29, dudu.c...@gmail.com <dudu.c...@gmail.com> wrote:
Hi
I have the following playbook.  
In the environment.yml file I have a parameter "tls=true"

In the below task , In tghe URL I would put https if tls=true and http if false.
Try:

        url: "http{{ 's' if tls else '' }}://{{ server.hostname }}.{{ domain }}:9999/api//{{ cluster_name }}"


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages