Ansible not loading variables properly

0 votes

This is my ansible setup hierarchy: 

symfony:
    env: prod
    owner: narayan
    cache_owner: files
    cache_group: files
    deploy_base: /opt/symfony
    keep_count: 2

My yaml file:

deploy.yml:

# ...
  - name: roll forward latest release
    symfony_preload: version="{{ symfony.deploy_version }}" deploy_base="{{ symfony.deploy_base }}"

I'm executing the playbook in the following way:

/usr/bin/ansible-playbook deploy.yml -i inventory/hosts \
    -e deploy_hosts=stg-web \
    -e symfony.deploy_version="$UPSTREAM_BUILD_NUMBER" \
    -e symfony.env="stg"

But ansible isn't loading variables properly. Why?

Feb 4 in Ansible by Narayan
54 views

1 answer to this question.

0 votes

group_vars/all/main.yml:

symfony:
    env: "{{ ENV }}"
    owner: Narayana
    cache_owner: files
    cache_group: files
    deploy_base: /opt/symfony
    keep_count: 2
    deploy_version: "{{ DEPLOY_VERSION }}"
    deploy_hosts: "{{ DEPLOY_HOSTS }}"

Then call your Ansible like this:

/usr/bin/ansible-playbook deploy.yml -i inventory/hosts \
    -e "DEPLOY_HOSTS=stg-web" \
    -e "DEPLOY_VERSION$UPSTREAM_BUILD_NUMBER" \
    -e "ENV=stg"

Hope this help :)

answered Feb 4 by anonymous

Related Questions In Ansible

0 votes
1 answer

When conditional not working in Ansible

Your identation is wrong and when is ...READ MORE

answered Apr 27, 2018 in Ansible by ajs3033
• 7,280 points
721 views
0 votes
2 answers

ansible-command not found

Use some other variable instead of PATH. READ MORE

answered Apr 23 in Ansible by Vismaya
2,884 views
0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,810 points
4,438 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
152 views
0 votes
1 answer
0 votes
1 answer

How do I access environment variables in Ansible?

Yes @Nagray, you're right! You can access ...READ MORE

answered Jan 24 in Ansible by Tessie
800 views
0 votes
1 answer

Define variables in Ansible Playbook

Variable names should be letters, numbers, and ...READ MORE

answered Jan 24 in Ansible by Jinha
55 views