Commit 17be6b20 by Max Rothman

Merge pull request #1847 from edx/max/refactor-minos

refactor minos to use new edx_service role
parents 63565290 b7c9e1b1
...@@ -110,10 +110,11 @@ ...@@ -110,10 +110,11 @@
- name: set git fetch.prune to ignore deleted remote refs - name: set git fetch.prune to ignore deleted remote refs
shell: git config --global fetch.prune true shell: git config --global fetch.prune true
sudo_user: "{{ edx_service_user }}" sudo_user: "{{ edx_service_user }}"
when: edx_service_repos is defined
- name: validate git protocol - name: validate git protocol
fail: msg='REPOS.PROTOCOL must be "https" or "ssh"' fail: msg='REPOS.PROTOCOL must be "https" or "ssh"'
when: (item.PROTOCOL != "https") and (item.PROTOCOL != "ssh") when: (item.PROTOCOL != "https") and (item.PROTOCOL != "ssh") and edx_service_repos is defined
with_items: edx_service_repos with_items: edx_service_repos
- name: install read-only ssh key - name: install read-only ssh key
...@@ -121,7 +122,7 @@ ...@@ -121,7 +122,7 @@
dest="{{ edx_service_home }}/.ssh/{{ item.REPO }}" dest="{{ edx_service_home }}/.ssh/{{ item.REPO }}"
content="{{ item.SSH_KEY }}" owner={{ edx_service_user }} content="{{ item.SSH_KEY }}" owner={{ edx_service_user }}
group={{ edx_service_user }} mode=0600 group={{ edx_service_user }} mode=0600
when: item.PROTOCOL == "ssh" when: item.PROTOCOL == "ssh" and edx_service_repos is defined
with_items: edx_service_repos with_items: edx_service_repos
- name: checkout code over ssh - name: checkout code over ssh
...@@ -131,7 +132,7 @@ ...@@ -131,7 +132,7 @@
accept_hostkey=yes key_file={{ edx_service_home }}/.ssh/{{ item.REPO }} accept_hostkey=yes key_file={{ edx_service_home }}/.ssh/{{ item.REPO }}
sudo_user: "{{ edx_service_user }}" sudo_user: "{{ edx_service_user }}"
register: code_checkout register: code_checkout
when: item.PROTOCOL == "ssh" when: item.PROTOCOL == "ssh" and edx_service_repos is defined
with_items: edx_service_repos with_items: edx_service_repos
- name: checkout code over https - name: checkout code over https
...@@ -140,7 +141,7 @@ ...@@ -140,7 +141,7 @@
dest={{ item.DESTINATION }} version={{ item.VERSION }} dest={{ item.DESTINATION }} version={{ item.VERSION }}
sudo_user: "{{ edx_service_user }}" sudo_user: "{{ edx_service_user }}"
register: code_checkout register: code_checkout
when: item.PROTOCOL == "https" when: item.PROTOCOL == "https" and edx_service_repos is defined
with_items: edx_service_repos with_items: edx_service_repos
...@@ -153,7 +154,7 @@ ...@@ -153,7 +154,7 @@
args: args:
tags: tags:
"version:{{edx_service_name}}" : "{{ item.0.DOMAIN }}/{{ item.0.PATH }}/{{ item.0.REPO }} {{ item.1.after |truncate(7,True,'') }}" "version:{{edx_service_name}}" : "{{ item.0.DOMAIN }}/{{ item.0.PATH }}/{{ item.0.REPO }} {{ item.1.after |truncate(7,True,'') }}"
when: item.1.after is defined and ansible_ec2_instance_id is defined when: item.1.after is defined and ansible_ec2_instance_id is defined and edx_service_repos is defined
with_together: with_together:
- edx_service_repos - edx_service_repos
- code_checkout.results - code_checkout.results
......
...@@ -12,17 +12,21 @@ ...@@ -12,17 +12,21 @@
# #
MINOS_GIT_IDENTITY: !!null MINOS_GIT_IDENTITY: !!null
MINOS_SERVICE_CONFIG:
aws_profile: !!null
s3_bucket: edx-{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}
bucket_path: lifecycle/minos
voter_conf_d: "{{ minos_voter_cfg }}"
# #
# vars are namespace with the module name. # vars are namespace with the module name.
# #
minos_role_name: minos minos_service_name: minos
minos_service_name: "{{ minos_role_name }}" minos_data_dir: "{{ COMMON_DATA_DIR }}/{{ minos_service_name }}"
minos_data_dir: "{{ COMMON_DATA_DIR }}/minos" minos_app_dir: "{{ COMMON_APP_DIR }}/{{ minos_service_name }}"
minos_app_dir: "{{ COMMON_APP_DIR }}/minos" minos_log_dir: "{{ COMMON_LOG_DIR }}/{{ minos_service_name }}"
minos_venv_dir: "{{ minos_app_dir }}/venvs/" minos_cfg_file: "{{ COMMON_CFG_DIR }}/{{ minos_service_name }}/minos.yml"
minos_log_dir: "{{ COMMON_LOG_DIR }}/minos" minos_voter_cfg: "{{ COMMON_CFG_DIR }}/{{ minos_service_name }}/conf.d/"
minos_cfg_file: "{{ COMMON_CFG_DIR }}/minos/minos.yml"
minos_voter_cfg: "{{ COMMON_CFG_DIR }}/minos/conf.d/"
minos_git_ssh: "/tmp/git.sh" minos_git_ssh: "/tmp/git.sh"
minos_git_identity: "{{ minos_app_dir }}/minos-git-identity" minos_git_identity: "{{ minos_app_dir }}/minos-git-identity"
minos_edx_server_tools_repo: "git@github.com/edx-ops/edx-minos.git" minos_edx_server_tools_repo: "git@github.com/edx-ops/edx-minos.git"
......
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Handlers for role minos
#
# Overview:
#
#
- name: notify me
debug: msg="stub handler"
...@@ -20,5 +20,7 @@ ...@@ -20,5 +20,7 @@
# } # }
dependencies: dependencies:
- role: edx_service - role: edx_service
edx_role_name: "{{ minos_role_name }}" edx_service_name: "{{ minos_service_name }}"
edx_service_name: "{{ minos_service_name }}" edx_service_config: "{{ MINOS_SERVICE_CONFIG }}"
\ No newline at end of file edx_service_user: root
edx_service_home: "{{ minos_app_dir }}"
\ No newline at end of file
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
# - minos # - minos
# #
- name: gather ec2 facts
action: ec2_facts
- name: create minos config directory - name: create minos config directory
file: > file: >
path={{ minos_voter_cfg }} path={{ minos_voter_cfg }}
...@@ -44,12 +41,6 @@ ...@@ -44,12 +41,6 @@
owner=root owner=root
group=root group=root
mode=0755 mode=0755
- name: create minos config
template: >
dest={{ minos_cfg_file }}
src=edx/etc/minos/minos.yml.j2
mode=0755 owner=root group=root
- name: create minos voters configs - name: create minos voters configs
template: > template: >
...@@ -81,13 +72,13 @@ ...@@ -81,13 +72,13 @@
- name: install read-only ssh key - name: install read-only ssh key
copy: > copy: >
content="{{ COMMON_GIT_IDENTITY }}" dest="{{ minos_git_identity }}" content="{{ MINOS_GIT_IDENTITY }}" dest="{{ minos_git_identity }}"
force=yes mode=0600 force=yes mode=0600
- name : install python custom-requirements - name : install python custom-requirements
pip: > pip: >
name="{{ item }}" name="{{ item }}"
virtualenv="{{ minos_venv_dir }}" virtualenv="{{ minos_app_dir }}/venvs/"
state=present state=present
extra_args="--exists-action w" extra_args="--exists-action w"
environment: environment:
......
---
aws_profile: !!null
s3_bucket: 'edx-{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}'
bucket_path: 'lifecycle/minos'
voter_conf_d: '{{ minos_voter_cfg }}'
#!/bin/sh #!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no {% if COMMON_GIT_IDENTITY %}-i {{ minos_git_identity }}{% endif %} "$@" exec /usr/bin/ssh -o StrictHostKeyChecking=no {% if MINOS_GIT_IDENTITY %}-i {{ minos_git_identity }}{% endif %} "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment