From aebdebcf192cf0b91550b1d274991f3486459ebe Mon Sep 17 00:00:00 2001 From: Ryan Heuser Date: Mon, 16 Oct 2023 14:12:09 -0400 Subject: [PATCH 1/9] start of shxco apache to nginx upgrade --- group_vars/shxco/vars.yml | 16 ++++++++++++---- playbooks/shxco_qa.yml | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/group_vars/shxco/vars.yml b/group_vars/shxco/vars.yml index 529a0a7b..a5744837 100644 --- a/group_vars/shxco/vars.yml +++ b/group_vars/shxco/vars.yml @@ -21,10 +21,18 @@ node_version: "10" clone_root: "/home/{{ deploy_user }}/repos" # don't distinguish between qa/prod paths install_root: "/srv/www/{{ app_name }}" -# apache location -apache_app_path: "/var/www/{{ app_name }}" -# use site name instead of 'mep' for apache site config -apache_conf_name: "shakespeareandco" + +# # apache location +# apache_app_path: "/var/www/{{ app_name }}" +# # use site name instead of 'mep' for apache site config +# apache_conf_name: "shakespeareandco" + +# set passenger defaults for production; override for other environments +passenger_app_root: "/var/www/{{ app_name }}" +passenger_server_name: "shakespeareandco.princeton.edu" +passenger_startup_file: "{{ app_name }}/wsgi.py" +passenger_python: "{{ passenger_app_root }}/env/bin/python" + # pul deploy user deploy_user: "conan" diff --git a/playbooks/shxco_qa.yml b/playbooks/shxco_qa.yml index 0f858bed..09c16b50 100644 --- a/playbooks/shxco_qa.yml +++ b/playbooks/shxco_qa.yml @@ -18,12 +18,13 @@ name: pulibrary.princeton_ansible.timezone - build_project_repo - postgresql + - passenger - build_npm - run_webpack # dependency for collectstatic - configure_logging # logging directory must exist before running django commands - django - solr_collection - - configure_apache + # - configure_apache - finalize_deploy - configure_crontab # used in prod but not always in qa - close_deployment \ No newline at end of file From c767d37e255fc63ff78e4774a0206254f61bdb2b Mon Sep 17 00:00:00 2001 From: Ryan Heuser Date: Tue, 17 Oct 2023 09:34:16 -0400 Subject: [PATCH 2/9] moving to qa --- group_vars/shxco/vars.yml | 7 ------- group_vars/shxco_qa/vars.yml | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/group_vars/shxco/vars.yml b/group_vars/shxco/vars.yml index a5744837..b90d9f9f 100644 --- a/group_vars/shxco/vars.yml +++ b/group_vars/shxco/vars.yml @@ -27,13 +27,6 @@ install_root: "/srv/www/{{ app_name }}" # # use site name instead of 'mep' for apache site config # apache_conf_name: "shakespeareandco" -# set passenger defaults for production; override for other environments -passenger_app_root: "/var/www/{{ app_name }}" -passenger_server_name: "shakespeareandco.princeton.edu" -passenger_startup_file: "{{ app_name }}/wsgi.py" -passenger_python: "{{ passenger_app_root }}/env/bin/python" - - # pul deploy user deploy_user: "conan" diff --git a/group_vars/shxco_qa/vars.yml b/group_vars/shxco_qa/vars.yml index 5e909738..8fda04a4 100644 --- a/group_vars/shxco_qa/vars.yml +++ b/group_vars/shxco_qa/vars.yml @@ -12,6 +12,11 @@ zk_host: "lib-zk-staging1:2181,lib-zk-staging2:2181,lib-zk-staging3:2181/solr8" solr_url: "http://lib-solr8-staging.princeton.edu:8983/solr/" solr_server: "{{ groups['solr_staging'][0] }}" +# set passenger defaults for production; override for other environments +passenger_app_root: "/var/www/{{ app_name }}" +passenger_server_name: "shakespeareandco.princeton.edu" +passenger_startup_file: "{{ app_name }}/wsgi.py" +passenger_python: "{{ passenger_app_root }}/env/bin/python" # configure scripts to run as cron jobs crontab: From c23041c9dfd2c6cb95bc46ec269a2d4003843703 Mon Sep 17 00:00:00 2001 From: Ryan Heuser Date: Wed, 18 Oct 2023 11:48:10 -0400 Subject: [PATCH 3/9] node version change --- group_vars/shxco/vars.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/group_vars/shxco/vars.yml b/group_vars/shxco/vars.yml index b90d9f9f..1dda19c1 100644 --- a/group_vars/shxco/vars.yml +++ b/group_vars/shxco/vars.yml @@ -12,10 +12,10 @@ django_app: "{{ python_app }}" symlink: mep # wsgi file relative to deploy location wsgi_path: "{{ django_app }}/wsgi.py" -# use python 3.6 -python_version: 3.6 +# use python 3.8 +python_version: 3.8 # nodejs version -node_version: "10" +node_version: "18" # Override clone root to use deploy user home instead of root clone_root: "/home/{{ deploy_user }}/repos" From b5d9922d8c67bcddc1af9edc0fab20d8fe9d337e Mon Sep 17 00:00:00 2001 From: Ryan Heuser Date: Wed, 18 Oct 2023 14:33:21 -0400 Subject: [PATCH 4/9] vars change for passenger --- group_vars/shxco/vars.yml | 9 +++++---- group_vars/shxco_qa/vars.yml | 7 ++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/group_vars/shxco/vars.yml b/group_vars/shxco/vars.yml index 1dda19c1..ac7275f8 100644 --- a/group_vars/shxco/vars.yml +++ b/group_vars/shxco/vars.yml @@ -22,10 +22,11 @@ clone_root: "/home/{{ deploy_user }}/repos" # don't distinguish between qa/prod paths install_root: "/srv/www/{{ app_name }}" -# # apache location -# apache_app_path: "/var/www/{{ app_name }}" -# # use site name instead of 'mep' for apache site config -# apache_conf_name: "shakespeareandco" +# set passenger defaults for production; override for other environments +passenger_app_root: "/var/www/{{ app_name }}" +passenger_server_name: "shakespeareandco.princeton.edu" +passenger_startup_file: "{{ app_name }}/wsgi.py" +passenger_python: "{{ passenger_app_root }}/env/bin/python" # pul deploy user deploy_user: "conan" diff --git a/group_vars/shxco_qa/vars.yml b/group_vars/shxco_qa/vars.yml index 8fda04a4..40d6ea92 100644 --- a/group_vars/shxco_qa/vars.yml +++ b/group_vars/shxco_qa/vars.yml @@ -12,11 +12,8 @@ zk_host: "lib-zk-staging1:2181,lib-zk-staging2:2181,lib-zk-staging3:2181/solr8" solr_url: "http://lib-solr8-staging.princeton.edu:8983/solr/" solr_server: "{{ groups['solr_staging'][0] }}" -# set passenger defaults for production; override for other environments -passenger_app_root: "/var/www/{{ app_name }}" -passenger_server_name: "shakespeareandco.princeton.edu" -passenger_startup_file: "{{ app_name }}/wsgi.py" -passenger_python: "{{ passenger_app_root }}/env/bin/python" +# override passenger server name with qa hostname +passenger_server_name: "test-shakespeareandco.cdh.princeton.edu" # configure scripts to run as cron jobs crontab: From 3fe65482910e4a42a88c9824e14e8e91a9f1877e Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 12 Dec 2023 14:37:57 -0500 Subject: [PATCH 5/9] Skip updating cache for bionic Co-authored-by: Ryan Heuser --- roles/passenger/tasks/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/passenger/tasks/main.yml b/roles/passenger/tasks/main.yml index c4fc486c..9e74e502 100644 --- a/roles/passenger/tasks/main.yml +++ b/roles/passenger/tasks/main.yml @@ -54,6 +54,9 @@ become: true ansible.builtin.apt: update_cache: true + # update cache fails on bionic because postgres no longer has a release + # only update cache on newer VMs; skip updating on older vms + when: ansible_distribution_version != "18.04" # Nginx and passenger installation. - name: Install Nginx and Passenger. From 891869241dc885ad6cefa746839bc257f7a0ddac Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 12 Dec 2023 14:39:20 -0500 Subject: [PATCH 6/9] Force snap refresh to change node version resolves #143 Co-authored-by: Ryan Heuser --- roles/build_npm/tasks/main.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/roles/build_npm/tasks/main.yml b/roles/build_npm/tasks/main.yml index af8a831d..f3c50864 100644 --- a/roles/build_npm/tasks/main.yml +++ b/roles/build_npm/tasks/main.yml @@ -19,14 +19,17 @@ channel: "{{ node_version }}/stable" state: present when: ansible_distribution == "Ubuntu" + register: snap_results - # NOTE: upgrading nodejs on cdh-geniza1 failed; - # was able to get it working with refresh - # instead of install: - # sudo snap refresh node --channel=16 - # We may want to run refresh as a command, see - # https://serverfault.com/a/1025300 + # NOTE: upgrading nodejs with ansible snap fails, even though + # the documentation claims it should refresh when then channel changes. + # Manually run a refresh command to ensure version changes take effect, e.g.: + # sudo snap refresh node --channel=18 + # NOTE2: could add a node -v check and only refresh on mismatch + - name: Refresh nodejs to ensure version changes take effect + become: true + ansible.builtin.command: "snap refresh node --channel={{ node_version }}/stable" - name: install javascript dependencies with npm become: true From 8f854b43d71c0852ae2c999a5ee4f05f23dd9e21 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 12 Dec 2023 14:48:32 -0500 Subject: [PATCH 7/9] Configure shxco for replication Co-authored-by: Ryan Heuser --- group_vars/shxco_qa/vars.yml | 13 +++++++++++-- playbooks/replicate.yml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/group_vars/shxco_qa/vars.yml b/group_vars/shxco_qa/vars.yml index 40d6ea92..1e829963 100644 --- a/group_vars/shxco_qa/vars.yml +++ b/group_vars/shxco_qa/vars.yml @@ -13,7 +13,16 @@ solr_url: "http://lib-solr8-staging.princeton.edu:8983/solr/" solr_server: "{{ groups['solr_staging'][0] }}" # override passenger server name with qa hostname -passenger_server_name: "test-shakespeareandco.cdh.princeton.edu" +application_url: "test-shakespeareandco.cdh.princeton.edu" + +# passenger settings +passenger_server_name: "{{ application_url }}" + + + + +# source host when replicating data/media (from ansible host inventory file) +replication_source_host: shxco_prod # configure scripts to run as cron jobs crontab: @@ -23,4 +32,4 @@ crontab: minute: 30 hour: 2 job: "bin/cron-wrapper {{ deploy }}/env/bin/python {{ deploy }}/manage.py twitterbot_100years schedule >> {{ logging_dir }}/twitterbot_100years.log 2>&1" - state: absent \ No newline at end of file + state: absent diff --git a/playbooks/replicate.yml b/playbooks/replicate.yml index 9aadf6fd..8fa87e83 100644 --- a/playbooks/replicate.yml +++ b/playbooks/replicate.yml @@ -14,7 +14,7 @@ # source hosts tasks - name: Generate database and media backups on source host - hosts: geniza_prod, cdhweb_prod, prosody_prod + hosts: geniza_prod, cdhweb_prod, prosody_prod, shxco_prod connection: ssh remote_user: pulsys # generate backups on source host @@ -48,7 +48,7 @@ - name: Restore database and media backups on target host # hosts: dev # connection: local - hosts: geniza_qa, cdhweb_qa, prosody_qa + hosts: geniza_qa, cdhweb_qa, prosody_qa, shxco_qa connection: ssh remote_user: pulsys vars: From a030cd850ec44f93ca9f192ca4483441bf70b6a3 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Wed, 20 Dec 2023 16:13:26 -0500 Subject: [PATCH 8/9] Remove postgresql apt repository for bionic machines (no longer avail) --- roles/postgresql/tasks/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/postgresql/tasks/main.yml b/roles/postgresql/tasks/main.yml index a42a9c44..f27f61f8 100644 --- a/roles/postgresql/tasks/main.yml +++ b/roles/postgresql/tasks/main.yml @@ -29,6 +29,19 @@ repo: "{{ postgres_apt_repository }}" update_cache: true state: present + when: ansible_distribution_version != '18.04' + +- name: Remove postgres repository for bionic (no longer valid) + become: true + tags: + - setup + - never + ansible.builtin.apt_repository: + repo: "{{ postgres_apt_repository }}" + update_cache: true + state: absent + when: ansible_distribution_version == '18.04' + - name: Install postgres client libraries become: true From 1e17d92e5677a2136e420bd3d8deda45936d268d Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Wed, 20 Dec 2023 16:14:27 -0500 Subject: [PATCH 9/9] Update shxco production playbook to match qa, apache2 -> nginx/passenger --- playbooks/shxco.yml | 4 ++-- playbooks/shxco_qa.yml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/playbooks/shxco.yml b/playbooks/shxco.yml index 7da491a5..0ae2439e 100644 --- a/playbooks/shxco.yml +++ b/playbooks/shxco.yml @@ -18,12 +18,12 @@ name: pulibrary.princeton_ansible.timezone - build_project_repo - postgresql + - passenger - build_npm - run_webpack # dependency for collectstatic - configure_logging # logging directory must exist before running django commands - django - solr_collection - - configure_apache - finalize_deploy - configure_crontab # used in prod but not always in qa - - close_deployment \ No newline at end of file + - close_deployment diff --git a/playbooks/shxco_qa.yml b/playbooks/shxco_qa.yml index 09c16b50..fbd1c088 100644 --- a/playbooks/shxco_qa.yml +++ b/playbooks/shxco_qa.yml @@ -24,7 +24,6 @@ - configure_logging # logging directory must exist before running django commands - django - solr_collection - # - configure_apache - finalize_deploy - configure_crontab # used in prod but not always in qa - - close_deployment \ No newline at end of file + - close_deployment