putting a var inside "template expression" in task

10 views
Skip to first unread message

Yosef Yudilevich

unread,
Oct 17, 2016, 12:13:48 PM10/17/16
to Ansible Project
hi
i know that the way i put it here it wont work
but what is the proper way to do it? put {{ COUNT }} variable inside bucket_ram_quota: "{{ ( 800 / {{ COUNT }} ) | int }}" 

thanks
===================
example:


- hosts: group_of_couchbase_servers

  vars:
    COUNT: 2

  tasks:
    - name: create buckets
      run_once: true
      shell: "/opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 --bucket={{ item.bucket_name }} --bucket-type={{ item.bucket_type }} --bucket-port={{ item.bucket_port }} --bucket-ramsize={{ item.bucket_ram_quota }}  --bucket-replica={{ item.num_replicas }} -u {{ admin_user }} -p {{ admin_password }}"
      with_items:
        - { bucket_name: Test", bucket_type: 'couchbase', bucket_port: '11211', bucket_ram_quota: "{{ ( 800 / {{ COUNT }} ) | int }}", num_replicas: '1' }

Kai Stian Olstad

unread,
Oct 17, 2016, 2:18:53 PM10/17/16
to ansible...@googlegroups.com
On 17. okt. 2016 11:52, Yosef Yudilevich wrote:
> hi
> i know that the way i put it here it wont work
> but what is the proper way to do it? put {{ COUNT }} variable inside
> bucket_ram_quota: "{{ ( 800 / {{ COUNT }} ) | int }}"

You already have curly brackets, so remove the ones inside.

bucket_ram_quota: "{{ ( 800 / COUNT ) | int }}"

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages