> On 2015-12-10, at 23:13, Igor Cicimov <[email protected]> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4AAAA681-286D-40DB-B113-8DA9A1DF7CC8%40srebrnysen.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to