From 1c7a99a671870dbfff35807c9bb3e5025463fbb6 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Wed, 31 Jan 2018 17:23:08 +0100 Subject: [PATCH] ansible-inventories/zehnder#317 Add MS ODBC driver to PHP role as an optional package --- defaults/main.yml | 1 + tasks/msodbc.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++++ tasks/php.yml | 4 ++++ 3 files changed, 57 insertions(+) create mode 100644 tasks/msodbc.yml diff --git a/defaults/main.yml b/defaults/main.yml index 76535af..94503fc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -46,6 +46,7 @@ php_max_file_uploads: '20' php_max_input_time: '60' php_max_input_vars: '1000' php_memory_limit: '32M' +php_needs_msodbc: false php_needs_oci8: false php_output_buffering: '4096' php_post_max_size: '32M' diff --git a/tasks/msodbc.yml b/tasks/msodbc.yml new file mode 100644 index 0000000..827aaa4 --- /dev/null +++ b/tasks/msodbc.yml @@ -0,0 +1,52 @@ +--- +# file: roles/php/tasks/msodbc.yml + +- name: "Apt Key" + apt_key: + url: 'https://packages.microsoft.com/keys/microsoft.asc' + state: 'present' + +- name: "Apt Repository" + apt_repository: + repo: 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod {{ ansible_distribution_release }} main' + state: 'present' + mode: '644' + +- name: "Install Packages" + apt: + pkg: '{{ item }}' + state: 'installed' + update_cache: yes + with_items: + - 'msodbcsql' + - 'mssql-tools' + - 'unixodbc-dev' + notify: + - "Apache | Restart Apache" + +- name: "PHP | Install PECL packages" + shell: 'pecl install {{ item }}' + with_items: + - 'sqlsrv' + - 'pdo_sqlsrv' + +- name: "Configuration files" + copy: + content: 'extension={{ item }}.so' + dest: '/etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini' + owner: 'root' + group: 'root' + mode: '644' + with_items: + - 'sqlsrv' + - 'pdo_sqlsrv' + notify: + - "Apache | Restart Apache" + +- name: "Enable extensions" + shell: 'phpenmod {{ item }}' + with_items: + - 'sqlsrv' + - 'pdo_sqlsrv' + notify: + - "Apache | Restart Apache" diff --git a/tasks/php.yml b/tasks/php.yml index c8f51dc..d63677d 100644 --- a/tasks/php.yml +++ b/tasks/php.yml @@ -111,6 +111,10 @@ when: repository is defined and php_needs_oci8 tags: 'always' +- include_tasks: msodbc.yml + when: php_needs_msodbc + tags: 'always' + - name: "PHP | Ensure ImageMagick config directory" file: dest={{ php_imagick_config_dir }} -- GitLab