%PDF- %PDF-
| Direktori : /proc/self/root/etc/ansible/roles/web/tasks/ |
| Current File : //proc/self/root/etc/ansible/roles/web/tasks/create_link.yml |
---
# create link site
#
# mandatory options:
# web_site_name - name for web server (ex. example.org)
# web_kernel_root - directory with kernel data (ex. /usr/share/bitrix)
#
# non-mandatory options:
# web_kernel_site - kernel site name ( playbook try found this name in the pool)
# web_site_dir - document root for new site
#
# ansible_playbook_file - all options can pass by yml file
######## load variables from groups config file
####
- name: gathering facts about kernel
delegate_to: "{{ cluster_web_server }}"
bx_facts: name=status password=0 site={{ web_kernel_site }} site_dir={{ web_kernel_root }}
tags: sites_facts
- name: create variable with kernel options
set_fact:
kernel_default: "{{ hostvars[inventory_hostname]['bx_sites'][0] }}"
tags: sites_facts
- name: set variables for kernel site
set_fact:
kernel_default_root: "{{ kernel_default.DocumentRoot }}"
kernel_default_charset: "{{ kernel_default.SiteCharset }}"
tags: sites_facts
- name: create additional variables when they not defined in the input
delegate_to: "{{ cluster_web_server }}"
bx_generate_site_vars: site_type={{ web_site_type }} site_name={{ web_site_name }}
site_dir={{ web_site_dir }}
register: site_vars
tags: configure_site
- name: set filesystem options for new site
set_fact:
web_site_shname: "{{ site_vars.site_short }}"
web_site_csync2: "{{ site_vars.site_csync2 }}"
web_site_root_dir: "{{ site_vars.site_dir }}"
web_site_sess_dir: "{{ site_extentend_php_sess }}/{{ web_site_name }}"
web_site_upld_dir: "{{ site_extentend_upload }}/{{ web_site_name }}"
tags: configure_site
- name: set charset options for new site
set_fact:
bitrix_site_encoding: cp1251
bitrix_site_collation: cp1251_general_ci
bitrix_site_php_overload: "php_admin_value mbstring.func_overload 0"
bitrix_site_php_internal: "php_admin_value mbstring.internal_encoding latin"
when: "kernel_default_charset == 'windows-1251'"
- name: set charset options for new site
set_fact:
bitrix_site_php_internal: "php_admin_value default_charset latin"
when: "kernel_default_charset == 'windows-1251' and php_older_version == 1"
# defined is_cluster and bx_sites_info variables
- include: bx_sites_info.yml
####
######## /load variables from groups config file
######## testing input options - to avoid the situation with overwriting existing data
######## 1. apache and nginx config
######## 2. directories: document root, sessions and uploads
######## 3. kernel contains bitrix, upload and images directory
####
- include: test_site_exist.yml
# test images, upload and bitrix directories
- name: check directory bitrix exists
stat:
path: "{{ kernel_default_root }}/bitrix"
register: bitrix_details
- name: check directory upload exists
stat:
path: "{{ kernel_default_root }}/upload"
register: upload_details
- name: check directory images exists
stat:
path: "{{ kernel_default_root }}/images"
register: images_details
- fail:
msg: "There are no directory {{ kernel_default_root }}/bitrix"
when: not bitrix_details.stat.exists|bool
- fail:
msg: "There are no directory {{ kernel_default_root }}/upload"
when: not upload_details.stat.exists|bool
- debug:
msg: "There are no directory {{ kernel_default_root }}/images"
when: not images_details.stat.exists|bool
####
######## /testing input options - to avoid the situation with overwriting existing data
######## create site directories on all web servers in the pool
####
- include: create_basic_dirs.yml
- name: create symbolic link to bitrix kernel directories
file:
dest: "{{ web_site_root_dir }}/{{ item }}"
src: "{{ kernel_default_root }}/{{ item }}"
state: link
owner: "{{ site_bitrix }}"
group: "{{ site_bitrix }}"
with_items:
- bitrix
- upload
tags: create_site_files
when: "'bitrix-web' in group_names"
- name: create symbolic link to images kernel directory
file:
dest: "{{ web_site_root_dir }}/images"
src: "{{ kernel_default_root }}/images"
state: link
owner: "{{ site_bitrix }}"
group: "{{ site_bitrix }}"
tags: create_site_files
when: images_details.stat.exists|bool and 'bitrix-web' in group_names
####
######## /create site directories on all web servers in the pool
######## create csync configuration and sync data for site between nodes for new site
####
- include: create_csync2_site.yml
when: "cluster_web_configure == 'enable' and fstype == 'csync'"
- include: configs_lsyncd_create_site.yml
when: "cluster_web_configure == 'enable' and fstype =='lsync'"
####
######## /create csync configuration and sync data for site between nodes for new site
######## create configs for web services
####
- include: create_web_configs.yml
when: "'bitrix-web' in group_names"
####
######## /create configs for web services
######## remove files
####
- file:
path: "{{ web_site_root_dir }}/bitrix/.settings.php.crm.orig"
state: absent
when: "'bitrix-web' in group_names"
####
####### /remove files