Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
182ddd9e
Unverified
Commit
182ddd9e
authored
Jun 24, 2016
by
arbabnazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite ansible tasks using YAML style
parent
7c91ca75
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
116 deletions
+166
-116
playbooks/roles/xserver/handlers/main.yml
+6
-6
playbooks/roles/xserver/tasks/deploy.yml
+99
-65
playbooks/roles/xserver/tasks/ec2.yml
+9
-8
playbooks/roles/xserver/tasks/main.yml
+52
-37
No files found.
playbooks/roles/xserver/handlers/main.yml
View file @
182ddd9e
...
@@ -15,10 +15,9 @@
...
@@ -15,10 +15,9 @@
#
#
-
name
:
restart xserver
-
name
:
restart xserver
supervisorctl
:
>
supervisorctl
:
name
=
xserver
name
:
xserver
supervisorctl_path
={{ supervisor_ctl }}
supervisorctl_path
:
"
{{
supervisor_ctl
}}"
config
={{ supervisor_cfg }}
config
:
"
{{
supervisor_cfg
}}"
state
=
restarted
state
:
restarted
when
:
not disable_edx_services
when
:
not disable_edx_services
\ No newline at end of file
playbooks/roles/xserver/tasks/deploy.yml
View file @
182ddd9e
-
name
:
"
writing
supervisor
script"
-
name
:
Writing supervisor script
template
:
>
template
:
src=xserver.conf.j2 dest={{ supervisor_available_dir }}/xserver.conf
src
:
xserver.conf.j2
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
dest
:
"
{{
supervisor_available_dir
}}/xserver.conf"
owner
:
"
{{
supervisor_user
}}"
group
:
"
{{
common_web_user
}}"
mode
:
"
0644"
-
name
:
"
enable
supervisor
script"
-
name
:
Enable supervisor script
file
:
>
file
:
src={{ supervisor_available_dir }}/xserver.conf
src
:
"
{{
supervisor_available_dir
}}/xserver.conf"
dest={{ supervisor_cfg_dir }}/xserver.conf
dest
:
"
{{
supervisor_cfg_dir
}}/xserver.conf"
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
owner
:
"
{{
supervisor_user
}}"
state=link force=yes
group
:
"
{{
common_web_user
}}"
mode
:
"
0644"
state
:
link
force
:
yes
when
:
not disable_edx_services
when
:
not disable_edx_services
-
name
:
"
add
gunicorn
configuration
file"
-
name
:
Add gunicorn configuration file
template
:
>
template
:
src=xserver_gunicorn.py.j2 dest={{ xserver_app_dir }}/xserver_gunicorn.py
src
:
xserver_gunicorn.py.j2
dest
:
"
{{
xserver_app_dir
}}/xserver_gunicorn.py"
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
notify
:
notify
:
-
restart xserver
-
restart xserver
-
name
:
checkout code
-
name
:
Checkout code
git_2_0_1
:
>
git_2_0_1
:
dest={{ xserver_code_dir }} repo={{ xserver_source_repo }} version={{xserver_version}}
dest
:
"
{{
xserver_code_dir
}}"
accept_hostkey=yes
repo
:
"
{{
xserver_source_repo
}}"
version
:
"
{{xserver_version}}"
accept_hostkey
:
yes
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
register
:
xserver_checkout
register
:
xserver_checkout
notify
:
restart xserver
notify
:
-
restart xserver
-
name
:
install requirements
-
name
:
Install requirements
pip
:
>
pip
:
requirements="{{ xserver_requirements_file }}" virtualenv="{{ xserver_venv_dir }}" state=present
requirements
:
"
{{
xserver_requirements_file
}}"
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
virtualenv
:
"
{{
xserver_venv_dir
}}"
state
:
present
extra_args
:
"
-i
{{
COMMON_PYPI_MIRROR_URL
}}"
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
notify
:
restart xserver
notify
:
-
restart xserver
-
name
:
install sandbox requirements
-
name
:
Install sandbox requirements
pip
:
>
pip
:
requirements="{{ xserver_requirements_file }}" virtualenv="{{ xserver_venv_sandbox_dir }}" state=present
requirements
:
"
{{
xserver_requirements_file
}}"
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
virtualenv
:
"
{{
xserver_venv_sandbox_dir
}}"
state
:
present
extra_args
:
"
-i
{{
COMMON_PYPI_MIRROR_URL
}}"
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
notify
:
restart xserver
notify
:
-
restart xserver
-
name
:
create xserver application config
-
name
:
Create xserver application config
template
:
src=xserver.env.json.j2 dest={{ xserver_app_dir }}/env.json
template
:
src
:
xserver.env.json.j2
dest
:
"
{{
xserver_app_dir
}}/env.json"
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
notify
:
restart xserver
notify
:
-
restart xserver
-
name
:
install read-only ssh key for the content repo that is required for grading
-
name
:
Install read-only ssh key for the content repo that is required for grading
copy
:
>
copy
:
content="{{ XSERVER_GIT_IDENTITY }}" dest={{ xserver_git_identity }}
content
:
"
{{
XSERVER_GIT_IDENTITY
}}"
owner={{ xserver_user }} group={{ xserver_user }} mode=0600
dest
:
"
{{
xserver_git_identity
}}"
notify
:
restart xserver
owner
:
"
{{
xserver_user
}}"
group
:
"
{{
xserver_user
}}"
mode
:
"
0600"
notify
:
-
restart xserver
-
name
:
upload ssh script
-
name
:
Upload ssh script
template
:
>
template
:
src=git_ssh.sh.j2 dest=/tmp/git_ssh.sh
src
:
git_ssh.sh.j2
owner={{ xserver_user }} mode=750
dest
:
"
/tmp/git_ssh.sh"
notify
:
restart xserver
owner
:
"
{{
xserver_user
}}"
mode
:
"
750"
notify
:
-
restart xserver
-
name
:
checkout grader code
-
name
:
Checkout grader code
git_2_0_1
:
>
git_2_0_1
:
dest={{ XSERVER_GRADER_DIR }} repo={{ XSERVER_GRADER_SOURCE }} version={{ xserver_grader_version }}
dest
:
"
{{
XSERVER_GRADER_DIR
}}"
accept_hostkey=yes
repo
:
"
{{
XSERVER_GRADER_SOURCE
}}"
version
:
"
{{
xserver_grader_version
}}"
accept_hostkey
:
yes
environment
:
environment
:
GIT_SSH
:
/tmp/git_ssh.sh
GIT_SSH
:
"
/tmp/git_ssh.sh"
notify
:
restart xserver
notify
:
-
restart xserver
register
:
xserver_grader_checkout
register
:
xserver_grader_checkout
become_user
:
"
{{
xserver_user
}}"
become_user
:
"
{{
xserver_user
}}"
-
name
:
remove read-only ssh key for the content repo
-
name
:
Remove read-only ssh key for the content repo
file
:
path={{ xserver_git_identity }} state=absent
file
:
notify
:
restart xserver
path
:
"
{{
xserver_git_identity
}}"
state
:
absent
notify
:
-
restart xserver
# call supervisorctl update. this reloads
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the supervisorctl config and restarts
# the services if any of the configurations
# the services if any of the configurations
# have changed.
# have changed.
#
#
-
name
:
u
pdate supervisor configuration
-
name
:
U
pdate supervisor configuration
shell
:
"
{{
supervisor_ctl
}}
-c
{{
supervisor_cfg
}}
update"
shell
:
"
{{
supervisor_ctl
}}
-c
{{
supervisor_cfg
}}
update"
register
:
supervisor_update
register
:
supervisor_update
changed_when
:
supervisor_update.stdout is defined and supervisor_update.stdout != ""
changed_when
:
supervisor_update.stdout is defined and supervisor_update.stdout != ""
when
:
not disable_edx_services
when
:
not disable_edx_services
-
name
:
e
nsure xserver is started
-
name
:
E
nsure xserver is started
supervisorctl
:
>
supervisorctl
:
name
=
xserver
name
:
xserver
supervisorctl_path
={{ supervisor_ctl }}
supervisorctl_path
:
"
{{
supervisor_ctl
}}"
config
={{ supervisor_cfg }}
config
:
"
{{
supervisor_cfg
}}"
state
=
started
state
:
started
when
:
not disable_edx_services
when
:
not disable_edx_services
-
name
:
c
reate a symlink for venv python
-
name
:
C
reate a symlink for venv python
file
:
>
file
:
src
=
"{{ xserver_venv_bin }}/{{ item }}"
src
:
"
{{
xserver_venv_bin
}}/{{
item
}}"
dest
={{ COMMON_BIN_DIR }}/{{ item }}.xserver
dest
:
"
{{
COMMON_BIN_DIR
}}/{{
item
}}.xserver"
state
=
link
state
:
link
with_items
:
with_items
:
-
python
-
python
-
pip
-
pip
-
name
:
e
nforce app-armor rules
-
name
:
E
nforce app-armor rules
command
:
aa-enforce {{ xserver_venv_sandbox_dir }}
command
:
"
aa-enforce
{{
xserver_venv_sandbox_dir
}}"
-
include
:
ec2.yml
tags=deploy
-
include
:
ec2.yml
when
:
COMMON_TAG_EC2_INSTANCE
when
:
COMMON_TAG_EC2_INSTANCE
tags
:
-
deploy
playbooks/roles/xserver/tasks/ec2.yml
View file @
182ddd9e
---
---
-
name
:
Get instance information
-
name
:
get instance information
action
:
ec2_facts
action
:
ec2_facts
-
name
:
tag instance for xserver
-
name
:
Tag instance for xserver
ec2_tag
:
resource={{ ansible_ec2_instance_id }} region={{ ansible_ec2_placement_region }}
ec2_tag
:
args
:
resource
:
"
{{
ansible_ec2_instance_id
}}"
region
:
"
{{
ansible_ec2_placement_region
}}"
tags
:
tags
:
"
version:xserver"
:
"
{{
xserver_source_repo
}}
{{
xserver_checkout.after|truncate(7,True,'')
}}"
"
version:xserver"
:
"
{{
xserver_source_repo
}}
{{
xserver_checkout.after|truncate(7,True,'')
}}"
when
:
xserver_checkout.after is defined
when
:
xserver_checkout.after is defined
-
name
:
tag instance for xserver grader
-
name
:
Tag instance for xserver grader
ec2_tag
:
resource={{ ansible_ec2_instance_id }} region={{ ansible_ec2_placement_region }}
ec2_tag
:
args
:
resource
:
"
{{
ansible_ec2_instance_id
}}"
region
:
"
{{
ansible_ec2_placement_region
}}"
tags
:
tags
:
"
version:xserver_grader"
:
"
{{
XSERVER_GRADER_SOURCE
}}
{{
xserver_grader_checkout.after|truncate(7,True,'')
}}"
"
version:xserver_grader"
:
"
{{
XSERVER_GRADER_SOURCE
}}
{{
xserver_grader_checkout.after|truncate(7,True,'')
}}"
when
:
xserver_grader_checkout.after is defined
when
:
xserver_grader_checkout.after is defined
playbooks/roles/xserver/tasks/main.yml
View file @
182ddd9e
...
@@ -2,37 +2,39 @@
...
@@ -2,37 +2,39 @@
# As of right now this role requires
# As of right now this role requires
# access to the edX 6.00x repo which is not public
# access to the edX 6.00x repo which is not public
---
---
-
name
:
Checking for grader info
-
name
:
checking for grader info
fail
:
fail
:
msg=
"You must define XSERVER_GRADER_DIR"
msg
:
"
You
must
define
XSERVER_GRADER_DIR"
when
:
XSERVER_GRADER_DIR|length == 0
when
:
XSERVER_GRADER_DIR|length == 0
-
fail
:
msg="You must define XSERVER_GRADER_SOURCE"
-
fail
:
msg
:
"
You
must
define
XSERVER_GRADER_SOURCE"
when
:
XSERVER_GRADER_SOURCE|length == 0
when
:
XSERVER_GRADER_SOURCE|length == 0
-
name
:
checking for git identity
-
name
:
Checking for git identity
fail
:
msg="You must define XSERVER_GIT_IDENTITY to use this role"
fail
:
msg
:
"
You
must
define
XSERVER_GIT_IDENTITY
to
use
this
role"
when
:
XSERVER_GIT_IDENTITY|length == 0
when
:
XSERVER_GIT_IDENTITY|length == 0
-
name
:
c
reate application user
-
name
:
C
reate application user
user
:
>
user
:
name
=
"{{ xserver_user }}"
name
:
"
{{
xserver_user
}}"
home
=
"{{ xserver_app_dir }}"
home
:
"
{{
xserver_app_dir
}}"
createhome
=
no
createhome
:
no
shell
=
/bin/false
shell
:
/bin/false
-
name
:
c
reate application sandbox user
-
name
:
C
reate application sandbox user
user
:
>
user
:
name
=
"{{ xserver_sandbox_user }}"
name
:
"
{{
xserver_sandbox_user
}}"
createhome
=
no
createhome
:
no
shell
=
/bin/false
shell
:
/bin/false
-
name
:
c
reate xserver app and data dirs
-
name
:
C
reate xserver app and data dirs
file
:
>
file
:
path
=
"{{ item }}"
path
:
"
{{
item
}}"
state
=
directory
state
:
directory
owner
=
"{{ xserver_user }}"
owner
:
"
{{
xserver_user
}}"
group
=
"{{ common_web_group }}"
group
:
"
{{
common_web_group
}}"
with_items
:
with_items
:
-
"
{{
xserver_app_dir
}}"
-
"
{{
xserver_app_dir
}}"
# needed for the ansible 1.5 git module
# needed for the ansible 1.5 git module
...
@@ -41,30 +43,43 @@
...
@@ -41,30 +43,43 @@
-
"
{{
xserver_data_dir
}}"
-
"
{{
xserver_data_dir
}}"
-
"
{{
xserver_data_dir
}}/data"
-
"
{{
xserver_data_dir
}}/data"
-
name
:
create sandbox sudoers file
-
name
:
Create sandbox sudoers file
template
:
src=99-sandbox.j2 dest=/etc/sudoers.d/99-sandbox owner=root group=root mode=0440
template
:
src
:
99-sandbox.j2
dest
:
"
/etc/sudoers.d/99-sandbox"
owner
:
root
group
:
root
mode
:
"
0440"
# Make sure this line is in the common-session file.
# Make sure this line is in the common-session file.
-
name
:
e
nsure pam-limits module is loaded
-
name
:
E
nsure pam-limits module is loaded
lineinfile
:
lineinfile
:
dest
=
/etc/pam.d/common-session
dest
:
/etc/pam.d/common-session
regexp
=
"session required pam_limits.so"
regexp
:
"
session
required
pam_limits.so"
line
=
"session required pam_limits.so"
line
:
"
session
required
pam_limits.so"
-
name
:
set sandbox limits
-
name
:
Set sandbox limits
template
:
src={{ item }} dest=/etc/security/limits.d/sandbox.conf
template
:
src
:
"
{{
item
}}"
dest
:
"
/etc/security/limits.d/sandbox.conf"
first_available_file
:
first_available_file
:
-
"
{{
secure_dir
}}/sandbox.conf.j2"
-
"
{{
secure_dir
}}/sandbox.conf.j2"
-
"
sandbox.conf.j2"
-
"
sandbox.conf.j2"
-
name
:
install system dependencies of xserver
-
name
:
Install system dependencies of xserver
apt
:
pkg={{ item }} state=present
apt
:
with_items
:
xserver_debian_pkgs
name
:
"
{{
item
}}"
state
:
present
with_items
:
"
{{
xserver_debian_pkgs
}}"
-
name
:
load python-sandbox apparmor profile
-
name
:
Load python-sandbox apparmor profile
template
:
src={{ item }} dest=/etc/apparmor.d/edx_apparmor_sandbox
template
:
src
:
"
{{
item
}}"
dest
:
"
/etc/apparmor.d/edx_apparmor_sandbox"
first_available_file
:
first_available_file
:
-
"
{{
secure_dir
}}/files/edx_apparmor_sandbox.j2"
-
"
{{
secure_dir
}}/files/edx_apparmor_sandbox.j2"
-
"
usr.bin.python-sandbox.j2"
-
"
usr.bin.python-sandbox.j2"
-
include
:
deploy.yml tags=deploy
-
include
:
deploy.yml
tags
:
-
deploy
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment