From 42c2a7a42e02ccb2e159488224bd0c46b5a00ffb Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 11:40:24 +0530 Subject: [PATCH 1/7] Issue #150912: Added role to deploy Joomla --- joomla.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 joomla.yml diff --git a/joomla.yml b/joomla.yml new file mode 100644 index 0000000..382d14a --- /dev/null +++ b/joomla.yml @@ -0,0 +1,8 @@ +--- +- hosts: all + become: false + vars: + workspace: "{{ lookup('env','WORKSPACE') }}" + vars_files: ["secrets/{{site_id}}"] + roles: + - joomla From 592eb3b5bfc87082598fe790c4535a0bf7969e7a Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 11:41:35 +0530 Subject: [PATCH 2/7] Issue #150912: Added role to deploy Joomla --- roles/joomla/defaults/main.yml | 90 ++++++++++++++++++++ roles/joomla/tasks/main.yml | 76 +++++++++++++++++ roles/joomla/templates/configuration.php.j2 | 92 +++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 roles/joomla/defaults/main.yml create mode 100644 roles/joomla/tasks/main.yml create mode 100644 roles/joomla/templates/configuration.php.j2 diff --git a/roles/joomla/defaults/main.yml b/roles/joomla/defaults/main.yml new file mode 100644 index 0000000..9800c5b --- /dev/null +++ b/roles/joomla/defaults/main.yml @@ -0,0 +1,90 @@ +--- +server_runs_as: "www-data" +server_runs_as_group: "www-data" + + # Joomla config variable +joomla_offline : "0" +joomla_offline_message : "This site is down for maintenance.
Please check back again soon." +joomla_display_offline_message : "1" +joomla_offline_image : "" +joomla_sitename : "" +joomla_editor : "tinymce" +joomla_captcha : "0" +joomla_list_limit : "20" +joomla_access : "1" +joomla_debug : "0" +joomla_debug_lang : "0" +joomla_dbtype : "mysqli" +joomla_live_site : "" +joomla_secret : "" +joomla_gzip : "0" +joomla_error_reporting : "none" +joomla_helpurl : "https://help.joomla.org/proxy/index.php?keyref:Help{major}{minor}:{keyref}" +joomla_ftp_host : "127.0.0.1" +joomla_ftp_port : "21" +joomla_ftp_user : "" +joomla_ftp_pass : "" +joomla_ftp_root : "" +joomla_ftp_enable : "0" +joomla_offset : "UTC" +joomla_mailonline : "1" +joomla_mailer : "mail" +joomla_mailfrom : "" +joomla_fromname : "" +joomla_sendmail : "/usr/sbin/sendmail" +joomla_smtpauth : "0" +joomla_smtpsecure : "none" +joomla_smtpport : "25" +joomla_caching : "0" +joomla_cache_handler : "file" +joomla_cachetime : "15" +joomla_cache_platformprefix : "0" +joomla_MetaDesc : "" +joomla_MetaKeys : "" +joomla_MetaTitle : "1" +joomla_MetaAuthor : "1" +joomla_MetaVersion : "0" +joomla_robots : "noindex, nofollow" +joomla_sef : "1" +joomla_sef_rewrite : "0" +joomla_sef_suffix : "0" +joomla_unicodeslugs : "0" +joomla_feed_limit : "10" +joomla_feed_email : "none" +joomla_log_path : "" +joomla_tmp_path : "" +joomla_lifetime : "180" +joomla_session_handler : "database" +joomla_memcache_persist : "1" +joomla_memcache_compress : "0" +joomla_memcache_server_host : "localhost" +joomla_memcache_server_port : "11211" +joomla_memcached_persist : "1" +joomla_memcached_compress : "0" +joomla_memcached_server_host : "localhost" +joomla_memcached_server_port : "11211" +joomla_redis_persist : "1" +joomla_redis_server_host : "localhost" +joomla_redis_server_port : "6379" +joomla_redis_server_auth : "" +joomla_redis_server_db : "0" +joomla_proxy_enable : "0" +joomla_proxy_host : "" +joomla_proxy_port : "" +joomla_proxy_user : "" +joomla_proxy_pass : "" +joomla_massmailoff : "0" +joomla_MetaRights : "" +joomla_sitename_pagetitles : "0" +joomla_force_ssl : "2" +joomla_session_memcache_server_host : "localhost" +joomla_session_memcache_server_port : "11211" +joomla_session_memcached_server_host : "localhost" +joomla_session_memcached_server_port : "11211" +joomla_frontediting : "1" +joomla_cookie_domain : "" +joomla_cookie_path : "" +joomla_asset_id : "1" + +# Cron list +cron_list: [] \ No newline at end of file diff --git a/roles/joomla/tasks/main.yml b/roles/joomla/tasks/main.yml new file mode 100644 index 0000000..f634fb1 --- /dev/null +++ b/roles/joomla/tasks/main.yml @@ -0,0 +1,76 @@ +- name: Create configuration.php + template: + src: "roles/joomla/templates/configuration.php.j2" + dest: "{{ doc_root }}/configuration.php" + owner: "{{ server_runs_as }}" + group: "{{ server_runs_as_group }}" + +- name: Create .htversion file + file: + path: "{{ doc_root }}/.htversion" + state: touch + owner: "{{ server_runs_as }}" + group: "{{ server_runs_as_group }}" + +- name: Write commit number .htversion to file + shell: echo "{{ lookup('env','BUILD_NUMBER') }}" > {{ doc_root }}/.htversion + +- name: Delete directories + file: + path: "{{ item.dest }}" + state: absent + with_items: + - {dest: '{{ doc_root }}/components'} + - {dest: '{{ doc_root }}/libraries'} + - {dest: '{{ doc_root }}/modules'} + - {dest: '{{ doc_root }}/plugins'} + - {dest: '{{ doc_root }}/language'} + - {dest: '{{ doc_root }}/cli'} + - {dest: '{{ doc_root }}/includes'} + - {dest: '{{ doc_root }}/layouts'} + - {dest: '{{ doc_root }}/templates'} + - {dest: '{{ doc_root }}/scripts'} + - {dest: '{{ doc_root }}/vendor'} + - {dest: '{{ doc_root }}/composer.json'} + - {dest: '{{ doc_root }}/composer.lock'} + +- name: Create required directories + file: + path: "{{ item.dest }}" + state: directory + with_items: + - {dest: '{{ doc_root }}/cache'} + - {dest: '{{ doc_root }}/tmp'} + - {dest: '{{ doc_root }}/logs'} + - {dest: '{{ doc_root }}/administrator'} + - {dest: '{{ doc_root }}/administrator/cache'} + +- name: create empty index.html files + file: path="{{ doc_root }}/{{ item }}/index.html" state=touch owner="{{server_runs_as}}" group="{{server_runs_as_group}}" + with_items: + - "cache" + - "tmp" + - "logs" + - "administrator/cache" + +- name: Unarchive artifact on remote server + unarchive: + src: "{{ workspace | default('') }}/{{ artifact_filename }}" + dest: "{{ doc_root }}" + copy: yes + owner: "{{ server_runs_as }}" + group: "{{ server_runs_as_group }}" + +- name: Create all wget cronjobs + become: false + tags: cron + cron: + name: "{{item.name}}" + minute: "{{item.minute}}" + hour: "{{item.hour}}" + job: "/usr/bin/wget --no-check-certificate -qO- '{{item.url}}' &> /dev/null" + with_items: "{{ cron_list }}" + +- name: Run composer.json to install extensions if any + shell: cd {{ doc_root }} && composer install + when: "{{ run_composer|default(false) }}" \ No newline at end of file diff --git a/roles/joomla/templates/configuration.php.j2 b/roles/joomla/templates/configuration.php.j2 new file mode 100644 index 0000000..15de796 --- /dev/null +++ b/roles/joomla/templates/configuration.php.j2 @@ -0,0 +1,92 @@ + Date: Fri, 4 Oct 2019 11:42:53 +0530 Subject: [PATCH 3/7] Issue #150912: Added role to deploy Joomla --- roles/joomla/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/joomla/defaults/main.yml b/roles/joomla/defaults/main.yml index 9800c5b..bb9ec4f 100644 --- a/roles/joomla/defaults/main.yml +++ b/roles/joomla/defaults/main.yml @@ -87,4 +87,4 @@ joomla_cookie_path : "" joomla_asset_id : "1" # Cron list -cron_list: [] \ No newline at end of file +cron_list: [] From 61bc300e5ce9b45faf35456237d640c0f63fb52b Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 11:43:28 +0530 Subject: [PATCH 4/7] Issue #150912: Added role to deploy Joomla --- roles/joomla/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/joomla/tasks/main.yml b/roles/joomla/tasks/main.yml index f634fb1..bc8925c 100644 --- a/roles/joomla/tasks/main.yml +++ b/roles/joomla/tasks/main.yml @@ -73,4 +73,4 @@ - name: Run composer.json to install extensions if any shell: cd {{ doc_root }} && composer install - when: "{{ run_composer|default(false) }}" \ No newline at end of file + when: "{{ run_composer|default(false) }}" From 47c1b144de899544406ee46033f43cee01bff299 Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 12:36:33 +0530 Subject: [PATCH 5/7] Issue #150912: Help doc for Joomla role --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 75a6c7a..c39fe7f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,70 @@ # Automating Common IT Infra Tasks -Repo that contains scripts to automate various infrastructure activities like developer workstation setup and configuration. + +Repo that contains scripts to automate various infrastructure activities like developer workstation setup and configuration. + + ## Setting up User Workstations + User workstations can be set up with the required development tools by running the following command in a terminal. Needs to be run by a user with sudo access. Script is tested to work on Ubuntu 16.04 & 14.04 although it might work with newer versions too. + + ```bash + sudo mkdir -p /tmp/ansible-ttpl-it-automation && sudo wget -q "https://raw.githubusercontent.com/techjoomla/infra-automation/master/ttpl_install.sh" -O /tmp/ansible-ttpl-it-automation/ttpl_install.sh && sudo chmod +x /tmp/ansible-ttpl-it-automation/ttpl_install.sh && sudo /tmp/ansible-ttpl-it-automation/ttpl_install.sh + ``` + The script will set up all the tools defined in the `environment-setup.yml` file and also set up 2 vhosts, one each for PHP5 & PHP7 -- To access the PHP5 localhost, navigate to http://machineusername-php5.local/ Eg: http://ttpl21-php5.local/ -- To access the PHP7 localhost, navigate to http://machineusername-php7.local/ Eg: http://ttpl21-php7.local/ + + +- To access the PHP5 localhost, navigate to http://machineusername-php5.local/ Eg: http://ttpl21-php5.local/ + +- To access the PHP7 localhost, navigate to http://machineusername-php7.local/ Eg: http://ttpl21-php7.local/ + - The files for this are present in /var/www/ttpl21-php5.local/public or in /var/www/ttpl21-php7.local/public + - PHP My Admin is not installed, so you can download Adminer (http://adminer.org/) and place the file anywhere in your local + + + +## Joomla site CI CD +1. Create folder `secret` alongside joomla.yml to store your server encrypted details (using ansible vault) + + ```javascript + joomla_user: "username" # Username to connect your host through ssh + joomla_password: "password" # Password to connect your host through ssh + joomla_db: "MYDB" # Database + joomla_host: "localhost" # Database host + joomla_dbprefix: "z467w_" # Table prefix + joomla_smtpuser: "" # SMTP Username + joomla_smtppass: "" # SMTP Password + joomla_smtphost: "localhost" # SMTP Host + ``` + +2. Create folder `inventory` alongside joomla.yml to store your server details and Joomla configurations + + E.g: + file: inventory/myserver + ```javascript + + [mysitegroup] + YOUR_SERVER_IP ansible_host=YOUR_SERVER_HOST ansible_user={{joomla_user}} ansible_ssh_private_key_file=SSH_KEY_PATH + + [mysitegroup:vars] + doc_root=/home/{{joomla_user}}/public_html # PATH To deploy Joomla files + site_id=myserver # Mame of secret file + deploy_env_domain=example.com # Site domain e.g example.com + server_runs_as=www-data # Owner of files + server_runs_as_group=www-data # Group of files + joomla_sitename="core Site" # Overridden Site name + joomla_log_path="/home/USER_NAME/public_html/logs" + joomla_tmp_path="/home/USER_NAME/public_html/tmp" + ``` + +### Run paybook +```bash +ansible-playbook -i inventory/myserver joomla.yml --vault-password-file=PATH_OF_VAULT_PASSWORD_FILE +``` \ No newline at end of file From 90cfc2b2cda16409a95ef1f04b423216dd88845b Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 12:37:16 +0530 Subject: [PATCH 6/7] Issue #150912: Help doc for Joomla role --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c39fe7f..16f6a83 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ The script will set up all the tools defined in the `environment-setup.yml` file joomla_tmp_path="/home/USER_NAME/public_html/tmp" ``` -### Run paybook +### Run playbook ```bash ansible-playbook -i inventory/myserver joomla.yml --vault-password-file=PATH_OF_VAULT_PASSWORD_FILE ``` \ No newline at end of file From 44547d120a229fb291d74f6774d80bf9820b37fa Mon Sep 17 00:00:00 2001 From: amol_g Date: Fri, 4 Oct 2019 12:40:40 +0530 Subject: [PATCH 7/7] Issue #150912: Help doc for Joomla role --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 16f6a83..bb192b5 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,14 @@ The script will set up all the tools defined in the `environment-setup.yml` file 1. Create folder `secret` alongside joomla.yml to store your server encrypted details (using ansible vault) ```javascript - joomla_user: "username" # Username to connect your host through ssh - joomla_password: "password" # Password to connect your host through ssh + joomla_user: "username" # Username to connect your host through ssh + joomla_password: "password" # Password to connect your host through ssh joomla_db: "MYDB" # Database - joomla_host: "localhost" # Database host - joomla_dbprefix: "z467w_" # Table prefix - joomla_smtpuser: "" # SMTP Username - joomla_smtppass: "" # SMTP Password - joomla_smtphost: "localhost" # SMTP Host + joomla_host: "localhost" # Database host + joomla_dbprefix: "z467w_" # Table prefix + joomla_smtpuser: "" # SMTP Username + joomla_smtppass: "" # SMTP Password + joomla_smtphost: "localhost" # SMTP Host ``` 2. Create folder `inventory` alongside joomla.yml to store your server details and Joomla configurations @@ -54,14 +54,14 @@ The script will set up all the tools defined in the `environment-setup.yml` file YOUR_SERVER_IP ansible_host=YOUR_SERVER_HOST ansible_user={{joomla_user}} ansible_ssh_private_key_file=SSH_KEY_PATH [mysitegroup:vars] - doc_root=/home/{{joomla_user}}/public_html # PATH To deploy Joomla files - site_id=myserver # Mame of secret file - deploy_env_domain=example.com # Site domain e.g example.com - server_runs_as=www-data # Owner of files - server_runs_as_group=www-data # Group of files - joomla_sitename="core Site" # Overridden Site name - joomla_log_path="/home/USER_NAME/public_html/logs" - joomla_tmp_path="/home/USER_NAME/public_html/tmp" + doc_root=/home/{{joomla_user}}/public_html # PATH to deploy Joomla files + site_id=myserver # Name of secret file + deploy_env_domain=example.com # Site domain e.g example.com + server_runs_as=www-data # Server user + server_runs_as_group=www-data # Group of files + joomla_sitename="core Site" # Overridden site name + joomla_log_path="/home/USER_NAME/public_html/logs" # Log path + joomla_tmp_path="/home/USER_NAME/public_html/tmp" # Tmp folder path ``` ### Run playbook