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
17d0469f
Commit
17d0469f
authored
Jul 07, 2016
by
Arbab Nazar
Committed by
GitHub
Jul 07, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3222 from edx/arbab/certs-rewrite
proper YAML syntax for rewriting ansible tasks
parents
5e4d036d
55b5ee74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
112 deletions
+130
-112
playbooks/roles/certs/tasks/deploy.yml
+79
-66
playbooks/roles/certs/tasks/main.yml
+46
-42
playbooks/roles/certs/tasks/tag_ec2.yml
+5
-4
No files found.
playbooks/roles/certs/tasks/deploy.yml
View file @
17d0469f
---
---
-
name
:
Create certificate application config and auth file
-
name
:
create certificate application config
template
:
template
:
>
src
:
"
{{
item.src
}}"
src=certs.env.json.j2
dest
:
"
{{
certs_app_dir
}}/{{
item.dest
}}"
dest={{ certs_app_dir }}/env.json
with_items
:
become_user
:
"
{{
certs_user
}}"
-
{
src
:
'
certs.env.json.j2'
,
dest
:
'
env.json'
}
-
{
src
:
'
certs.auth.json.j2'
,
dest
:
'
auth.json'
}
-
name
:
create certificate auth file
template
:
>
src=certs.auth.json.j2
dest={{ certs_app_dir }}/auth.json
become_user
:
"
{{
certs_user
}}"
become_user
:
"
{{
certs_user
}}"
-
name
:
writing supervisor script for certificates
-
name
:
Writing supervisor script for certificates
template
:
>
template
:
src=certs.conf.j2 dest={{ supervisor_available_dir }}/certs.conf
src
:
certs.conf.j2
owner={{ supervisor_user }} mode=0644
dest
:
"
{{
supervisor_available_dir
}}/certs.conf"
owner
:
"
{{
supervisor_user
}}"
mode
:
"
0644"
-
name
:
e
nable supervisor script for certificates
-
name
:
E
nable supervisor script for certificates
file
:
>
file
:
src
={{ supervisor_available_dir }}/certs.conf
src
:
"
{{
supervisor_available_dir
}}/certs.conf"
dest
={{ supervisor_cfg_dir }}/certs.conf
dest
:
"
{{
supervisor_cfg_dir
}}/certs.conf"
owner
={{ supervisor_user }}
owner
:
"
{{
supervisor_user
}}"
state
=
link
state
:
link
force
=
yes
force
:
yes
mode
=0644
mode
:
"
0644"
when
:
not disable_edx_services
when
:
not disable_edx_services
-
name
:
create ssh script for git
-
name
:
Create ssh script for git
template
:
>
template
:
src={{ certs_git_ssh|basename }}.j2 dest={{ certs_git_ssh }}
src
:
"
{{
certs_git_ssh
|
basename
}}.j2"
owner={{ certs_user }} mode=750
dest
:
"
{{
certs_git_ssh
}}"
owner
:
"
{{
certs_user
}}"
mode
:
"
0750"
# This key is only needed if you are pulling down a private
# This key is only needed if you are pulling down a private
# certificates repo
# certificates repo
-
name
:
install read-only ssh key for the certs repo
-
name
:
Install read-only ssh key for the certs repo
copy
:
>
copy
:
content="{{ CERTS_GIT_IDENTITY }}" dest={{ certs_git_identity }}
content
:
"
{{
CERTS_GIT_IDENTITY
}}"
force=yes owner={{ certs_user }} mode=0600
dest
:
"
{{
certs_git_identity
}}"
force
:
yes
owner
:
"
{{
certs_user
}}"
mode
:
"
0600"
when
:
CERTS_GIT_IDENTITY != "none"
when
:
CERTS_GIT_IDENTITY != "none"
-
name
:
checkout certificates repo into {{ certs_code_dir }}
-
name
:
"
Checkout
certificates
repo
into
{{
certs_code_dir
}}"
git_2_0_1
:
>
git_2_0_1
:
dest={{ certs_code_dir }} repo={{ CERTS_REPO }} version={{ certs_version }}
dest
:
"
{{
certs_code_dir
}}"
accept_hostkey=yes
repo
:
"
{{
CERTS_REPO
}}"
version
:
"
{{
certs_version
}}"
accept_hostkey
:
yes
become_user
:
"
{{
certs_user
}}"
become_user
:
"
{{
certs_user
}}"
environment
:
environment
:
GIT_SSH
:
"
{{
certs_git_ssh
}}"
GIT_SSH
:
"
{{
certs_git_ssh
}}"
register
:
certs_checkout
register
:
certs_checkout
when
:
CERTS_GIT_IDENTITY != "none"
when
:
CERTS_GIT_IDENTITY != "none"
-
name
:
checkout certificates repo into {{ certs_code_dir }}
-
name
:
Checkout certificates repo into {{ certs_code_dir }}
git_2_0_1
:
>
git_2_0_1
:
dest={{ certs_code_dir }} repo={{ CERTS_REPO }} version={{ certs_version }}
dest
:
"
{{
certs_code_dir
}}"
accept_hostkey=yes
repo
:
"
{{
CERTS_REPO
}}"
version
:
"
{{
certs_version
}}"
accept_hostkey
:
yes
become_user
:
"
{{
certs_user
}}"
become_user
:
"
{{
certs_user
}}"
register
:
certs_checkout
register
:
certs_checkout
when
:
CERTS_GIT_IDENTITY == "none"
when
:
CERTS_GIT_IDENTITY == "none"
-
name
:
remove read-only ssh key for the certs repo
-
name
:
Remove read-only ssh key for the certs repo
file
:
path={{ certs_git_identity }} state=absent
file
:
path
:
"
{{
certs_git_identity
}}"
state
:
absent
when
:
CERTS_GIT_IDENTITY != "none"
when
:
CERTS_GIT_IDENTITY != "none"
-
name
:
install python requirements
-
name
:
Install python requirements
pip
:
>
pip
:
requirements="{{ certs_requirements_file }}" virtualenv="{{ certs_venv_dir }}" state=present
requirements
:
"
{{
certs_requirements_file
}}"
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
virtualenv
:
"
{{
certs_venv_dir
}}"
state
:
present
extra_args
:
"
-i
{{
COMMON_PYPI_MIRROR_URL
}}"
become_user
:
"
{{
certs_user
}}"
become_user
:
"
{{
certs_user
}}"
# call supervisorctl update. this reloads
# call supervisorctl update. this reloads
...
@@ -73,38 +84,40 @@
...
@@ -73,38 +84,40 @@
# 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
become_user
:
"
{{
supervisor_service_user
}}"
become_user
:
"
{{
supervisor_service_user
}}"
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 certs has started
-
name
:
E
nsure certs has started
supervisorctl
:
>
supervisorctl
:
name
=
certs
name
:
certs
supervisorctl_path
={{ supervisor_ctl }}
supervisorctl_path
:
"
{{
supervisor_ctl
}}"
config
={{ supervisor_cfg }}
config
:
"
{{
supervisor_cfg
}}"
state
=
started
state
:
started
become_user
:
"
{{
supervisor_service_user
}}"
become_user
:
"
{{
supervisor_service_user
}}"
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
=
"{{ certs_venv_bin }}/{{ item }}"
src
:
"
{{
certs_venv_bin
}}/{{
item
}}"
dest
={{ COMMON_BIN_DIR }}/{{ item }}.certs
dest
:
"
{{
COMMON_BIN_DIR
}}/{{
item
}}.certs"
state
=
link
state
:
link
with_items
:
with_items
:
-
python
-
python
-
pip
-
pip
-
include
:
tag_ec2.yml
tags=deploy
-
include
:
tag_ec2.yml
when
:
COMMON_TAG_EC2_INSTANCE
when
:
COMMON_TAG_EC2_INSTANCE
tags
:
-
deploy
-
name
:
r
estart certs
-
name
:
R
estart certs
supervisorctl
:
>
supervisorctl
:
name
=
certs
name
:
certs
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
playbooks/roles/certs/tasks/main.yml
View file @
17d0469f
...
@@ -31,19 +31,19 @@
...
@@ -31,19 +31,19 @@
# - supervisor
# - supervisor
# - certs
# - certs
#
#
-
name
:
c
reate application user
-
name
:
C
reate application user
user
:
>
user
:
name
=
"{{ certs_user }}"
name
:
"
{{
certs_user
}}"
home
=
"{{ certs_app_dir }}"
home
:
"
{{
certs_app_dir
}}"
createhome
=
no
createhome
:
no
shell
=
/bin/false
shell
:
/bin/false
-
name
:
c
reate certs app dirs
-
name
:
C
reate certs app dirs
file
:
>
file
:
path
=
"{{ item }}"
path
:
"
{{
item
}}"
state
=
directory
state
:
directory
owner
=
"{{ certs_user }}"
owner
:
"
{{
certs_user
}}"
group
=
"{{ common_web_group }}"
group
:
"
{{
common_web_group
}}"
with_items
:
with_items
:
-
"
{{
certs_app_dir
}}"
-
"
{{
certs_app_dir
}}"
# needed for the ansible 1.5 git module
# needed for the ansible 1.5 git module
...
@@ -54,42 +54,46 @@
...
@@ -54,42 +54,46 @@
# The certs web root must be owned
# The certs web root must be owned
# by the web user so the certs service
# by the web user so the certs service
# can write files there.
# can write files there.
-
name
:
c
reate certs web root
-
name
:
C
reate certs web root
file
:
>
file
:
path
=
"{{ CERTS_WEB_ROOT }}"
path
:
"
{{
CERTS_WEB_ROOT
}}"
state
=
directory
state
:
directory
owner
=
"{{ common_web_group }}"
owner
:
"
{{
common_web_group
}}"
group
=
"{{ certs_user }}"
group
:
"
{{
certs_user
}}"
-
name
:
create certs gpg dir
-
name
:
Create certs gpg dir
file
:
>
file
:
path="{{ certs_gpg_dir }}" state=directory
path
:
"
{{
certs_gpg_dir
}}"
owner="{{ common_web_user }}"
state
:
directory
mode=0700
owner
:
"
{{
common_web_user
}}"
mode
:
"
0700"
-
name
:
copy the private gpg signing key
-
name
:
Copy the private gpg signing key
copy
:
>
copy
:
src={{ CERTS_LOCAL_PRIVATE_KEY }}
src
:
"
{{
CERTS_LOCAL_PRIVATE_KEY
}}"
dest={{ certs_app_dir }}/{{ CERTS_LOCAL_PRIVATE_KEY|basename }}
dest
:
"
{{
certs_app_dir
}}/{{
CERTS_LOCAL_PRIVATE_KEY
|
basename
}}"
owner={{ common_web_user }} mode=0600
owner
:
"
{{
common_web_user
}}"
mode
:
"
0600"
register
:
certs_gpg_key
register
:
certs_gpg_key
no_log
:
True
-
name
:
copy the pgp trust export
-
name
:
Copy the pgp trust export
copy
:
>
copy
:
content="{{ CERTS_OWNER_TRUST }}"
content
:
"
{{
CERTS_OWNER_TRUST
}}"
dest={{ certs_app_dir }}/trust.export
dest
:
"
{{
certs_app_dir
}}/trust.export"
owner={{ common_web_user }} mode=0600
owner
:
"
{{
common_web_user
}}"
mode
:
"
0600"
-
name
:
load the gpg key
-
name
:
Load the gpg key
shell
:
>
shell
:
"
/usr/bin/gpg
--homedir
{{
certs_gpg_dir
}}
--import
{{
certs_app_dir
}}/{{
CERTS_LOCAL_PRIVATE_KEY
|
basename
}}"
/usr/bin/gpg --homedir {{ certs_gpg_dir }} --import {{ certs_app_dir }}/{{ CERTS_LOCAL_PRIVATE_KEY|basename }}
become_user
:
"
{{
common_web_user
}}"
sudo_user
:
"
{{
common_web_user
}}"
when
:
certs_gpg_key.changed
when
:
certs_gpg_key.changed
-
name
:
import the trust export
-
name
:
Import the trust export
shell
:
>
shell
:
"
/usr/bin/gpg
--homedir
{{
certs_gpg_dir
}}
--import-ownertrust
{{
certs_app_dir
}}/trust.export"
/usr/bin/gpg --homedir {{ certs_gpg_dir }} --import-ownertrust {{ certs_app_dir }}/trust.export
become_user
:
"
{{
common_web_user
}}"
sudo_user
:
"
{{
common_web_user
}}"
when
:
certs_gpg_key.changed
when
:
certs_gpg_key.changed
-
include
:
deploy.yml tags=deploy
-
include
:
deploy.yml
tags
:
-
deploy
playbooks/roles/certs/tasks/tag_ec2.yml
View file @
17d0469f
---
---
-
name
:
g
et instance information
-
name
:
G
et instance information
action
:
ec2_facts
action
:
ec2_facts
-
name
:
tag instance
-
name
:
Tag instance
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:certs"
:
"
{{
CERT_REPO
}}
{{
certs_checkout.after|truncate(7,True,'')
}}"
"
version:certs"
:
"
{{
CERT_REPO
}}
{{
certs_checkout.after|truncate(7,True,'')
}}"
when
:
certs_checkout.after is defined
when
:
certs_checkout.after is defined
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