From 08c315866777e878eb05744dfd2f5847cd5b7e86 Mon Sep 17 00:00:00 2001 From: Dylan DiGeronimo Date: Wed, 11 Dec 2019 23:20:40 -0500 Subject: [PATCH] Began work on main production tasks --- .gitignore | 4 ++- group_vars/production/vars.yml | 7 ++++++ hosts | 2 ++ roles/cce_prod/tasks/main.yml | 46 ++++++++++++++++++++++++++++++++++ setup-prod.yml | 1 + 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 roles/cce_prod/tasks/main.yml diff --git a/.gitignore b/.gitignore index 2d50efe..53ff668 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -*.retry \ No newline at end of file +*.retry + +.vscode/ \ No newline at end of file diff --git a/group_vars/production/vars.yml b/group_vars/production/vars.yml index e69de29..426f8e6 100644 --- a/group_vars/production/vars.yml +++ b/group_vars/production/vars.yml @@ -0,0 +1,7 @@ +--- +# Variables for production server + +project_path: "~/cce-search-prototype" +user_name: "ubuntu" +git_repo: "https://github.com/EbookFoundation/cce-search-prototype" +git_branch: "master" \ No newline at end of file diff --git a/hosts b/hosts index e69de29..c255b13 100644 --- a/hosts +++ b/hosts @@ -0,0 +1,2 @@ +[production] +cce-prod ansible_host=cce.ebookfoundation.org ansible_user=ubuntu \ No newline at end of file diff --git a/roles/cce_prod/tasks/main.yml b/roles/cce_prod/tasks/main.yml new file mode 100644 index 0000000..29d9a6c --- /dev/null +++ b/roles/cce_prod/tasks/main.yml @@ -0,0 +1,46 @@ +--- +- name: Install prod dependencies + become: true + apt: + name: "{{ item }}" + update_cache: true + state: present + with_items: + - 'git' + - 'pipenv' + +- name: Create project directory + become: true + file: + path: "{{ project_path }}" + state: directory + owner: "{{ user_name }}" + mode: 0755 + +- name: Checkout repo + git: + accept_hostkey: yes + force: yes + repo: "{{ git_repo }}" + dest: "{{ project_path }}" + version: "{{ git_branch }}" + +# Source: https://github.com/pypa/pipenv/issues/363#issuecomment-421310544 +- name: Check for venv + ignore_errors: true + command: "pipenv --venv" + args: + chdir: "{{ project_path }}" + register: pipenv_venv_check_cmd + changed_when: + - ('No virtualenv' not in pipenv_venv_check_cmd.stderr) + +- name: Run pipenv install + command: "pipenv install" + args: + chdir: "{{ project_root }}" + when: + - ('No virtualenv' in pipenv_venv_check_cmd.stderr) + + +# TODO: open ports on firewall \ No newline at end of file diff --git a/setup-prod.yml b/setup-prod.yml index e69de29..eec0c59 100644 --- a/setup-prod.yml +++ b/setup-prod.yml @@ -0,0 +1 @@ +an \ No newline at end of file