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, 2019 in Ansible by Narayan
1,254 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, 2019 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,300 points
5,562 views
0 votes
2 answers

ansible-command not found

Use some other variable instead of PATH. READ MORE

answered Apr 23, 2019 in Ansible by Vismaya
10,871 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,890 points
18,952 views
0 votes
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,997 views
+2 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, 2019 in Ansible by Tessie
8,565 views
0 votes
1 answer

Define variables in Ansible Playbook

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

answered Jan 24, 2019 in Ansible by Jinha
1,326 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP