Also if you can put

- debug: var=destination

before and after every include call would be very helpful to see where the 
var actually gets changed.

Just realized that my previous message might not be clear enough, what I 
mean is add:

--extra-vars '{"destination":"some_value_here"}'

to the ansible-playbook command and move back all your vars in their 
respective defaults files as they were before.

On Friday, December 11, 2015 at 3:37:37 PM UTC+11, Igor Cicimov wrote:
>
> Just out of curiosity, what happens when you supply destination via 
> extra_vars and leave everything as it was in defaults file?
>
>
> On Friday, December 11, 2015 at 11:09:30 AM UTC+11, silverdr wrote:
>>
>>
>> > On 2015-12-10, at 23:13, Igor Cicimov <ig...@encompasscorporation.com> 
>> wrote: 
>> > 
>> > Strange, because I'm sure every time I call a tasks file from another 
>> role I have to explicitly include that role's defaults|vars file via 
>> vars_files to be able to use its variables. So you are saying you are 
>> seeing this happen without this linking. Do you mind showing us the whole 
>> main playbook? 
>>
>> FYI: I - kind of - worked the problem around by moving the variables from 
>> "defaults" to "vars" but this causes other inconveniences when I actually 
>> want to overwrite them. 
>>
>> Example playbook ({{destination}} value changes after the first -include: 
>>
>> --- 
>> - hosts: api 
>>   remote_user: teamcity 
>>   sudo: yes 
>>   gather_facts: no 
>>
>>   pre_tasks: 
>>
>>   roles: 
>>     - { role: "api" } 
>>
>>   tasks: 
>>
>>   post_tasks: 
>>
>> ************************************ 
>> roles/api/tasks/main.yml: 
>>
>> # Prerequisities / system dependencies 
>> - name: install dependencies 
>>   apt: name={{item}} state=present 
>>   with_items: 
>>     - python-httplib2 
>>     - supervisor 
>>
>> # Configuring PHP 
>> - include: php.yml 
>>
>> # Getting and preparing / installing the code 
>>
>> - name: if exists - remove previously cloned repository 
>>   file: 
>>     path: "{{destination}}" 
>>     state: absent 
>>   when: clear_destination is defined 
>>   tags: 
>>     - api 
>>
>> - name: clone repository 
>>   git: 
>>     repo: "{{repository}}" 
>>     dest: "{{destination}}" 
>>     accept_hostkey: yes 
>>   tags: 
>>     - api_debug 
>>
>> - name: copy default env file # TODO - process the env file out of 
>> env.dist 
>>   template: src=env.ini.j2 dest={{destination}}/api/.env 
>>   tags: env_file 
>>
>> - name: install using composer 
>>   composer: command=install working_dir={{destination}}/api/ no_dev=no 
>>
>> - name: change ownership of the cloned repository 
>>   file: dest={{destination}} owner={{owneruser}} group={{ownergroup}} 
>> state=directory recurse=yes 
>>
>> # Configuring database 
>> - name: stop supervisor service 
>>   supervisorctl: name='api:' state=stopped 
>>   tags: api_database 
>>
>> - include: database.yml 
>>
>> - name: run migrations 
>>   sudo_user: "{{owneruser}}" 
>>   command: php artisan migrate chdir={{destination}}/api/ 
>>
>> - name: seed the database 
>>   sudo_user: "{{owneruser}}" 
>>   command: php artisan db:seed chdir={{destination}}/api/ 
>>
>> # Cleaning elastic index 
>> - name: cleanup elastic index 
>>   uri: url=http://{{elastic_hostname}}:{{elastic_port}}/{{listing_index}} 
>> method=DELETE status_code=200,404 
>>   when: clean_elastic_index is defined 
>>   tags: 
>>     - clean_elastic_index 
>>
>> # Run artisan queue daemon with supervisord 
>> - name: copy queue daemon configuration 
>>   template: src=supervisord.conf.j2 dest=/etc/supervisor/conf.d/api.conf 
>>   tags: queue 
>>
>> - name: add new service 
>>   supervisorctl: name='api:' state=started 
>>   tags: queue 
>>
>> - name: start added service 
>>   supervisorctl: name='api:' state=restarted 
>>   tags: queue 
>>
>> # Configuring network 
>> - include: network.yml 
>>
>> # Configuring httpd 
>> - include: httpd.yml 
>>
>> # Generating apidocs 
>> - include: apidocs.yml 
>>
>> ****************************************** 
>> roles/api/tasks/php.yml: 
>>
>> --- 
>> - name: install php5 extensions 
>>   apt: name={{item}} state=present 
>>   with_items: 
>>     - php5-mcrypt 
>>     - php5-json 
>>     - php5-pgsql 
>>     - php5-xsl 
>>     - php5-gmp 
>>
>> - name: enable php5-mcrypt extension 
>>   command: php5enmod mcrypt 
>>   args: 
>>     creates: /etc/php5/apache2/conf.d/20-mcrypt.ini 
>>
>> # when installing xdebug make sure that xdebug.max_nesting_level = 250 
>> # is also set in the php's php.ini configuration file 
>> - name: install php5 xdebug extension 
>>   apt: name={{item}} state=present 
>>     - php5-xdebug 
>>   when: xdebug is defined 
>>
>> - name: set php5 xdebug configuration param 
>>   lineinfile: 
>>     dest: "{{php_ini_path}}" 
>>     backup: true 
>>     backrefs: true 
>>     state: present 
>>     regexp: "{{item.regexp}}" 
>>     line: "{{item.line}}" 
>>   with_items: 
>>     - {regexp: '^xdebug.max_nesting_level', line: 
>> 'xdebug.max_nesting_level = 250'} 
>>   notify: restart httpd 
>>   when: xdebug is defined 
>>
>>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a9d993c5-4c34-4872-b01f-2fee809dd5f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to