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
c3a58c5c
Commit
c3a58c5c
authored
Nov 12, 2015
by
Arbab Nazar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2464 from edx/arbab/rewrite-common
Arbab/rewrite common
parents
470156e3
89088af2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
81 deletions
+73
-81
playbooks/roles/common/defaults/main.yml
+12
-0
playbooks/roles/common/tasks/main.yml
+61
-81
playbooks/roles/common/templates/etc/cron.hourly/logrotate.j2
+0
-0
No files found.
playbooks/roles/common/defaults/main.yml
View file @
c3a58c5c
...
...
@@ -25,6 +25,18 @@ COMMON_USER_INFO: []
COMMON_BIN_DIR
:
"
{{
COMMON_BASE_DIR
}}/bin"
COMMON_CFG_DIR
:
"
{{
COMMON_BASE_DIR
}}/etc"
common_directories
:
-
path
:
"
{{
COMMON_DATA_DIR
}}"
-
path
:
"
{{
COMMON_APP_DIR
}}"
-
path
:
"
{{
COMMON_BIN_DIR
}}"
-
path
:
"
{{
COMMON_CFG_DIR
}}"
-
path
:
"
{{
COMMON_LOG_DIR
}}"
owner
:
"
{{
common_log_user
}}"
group
:
"
{{
common_log_user
}}"
-
path
:
"
/etc/logrotate.d/hourly"
-
path
:
"
/etc/rsyslog.d/50-default.conf"
state
:
absent
COMMON_ENVIRONMENT
:
'
default_env'
COMMON_DEPLOYMENT
:
'
default_deployment'
COMMON_PYPI_MIRROR_URL
:
'
https://pypi.python.org/simple'
...
...
playbooks/roles/common/tasks/main.yml
View file @
c3a58c5c
---
-
name
:
Update CA Certificates
shell
:
>
/usr/sbin/update-ca-certificates
shell
:
/usr/sbin/update-ca-certificates
-
name
:
Add user www-data
# This is the default user for nginx
user
:
>
name="{{ common_web_user }}"
shell=/bin/false
-
name
:
Create common directories
file
:
>
path={{ item }} state=directory owner=root
group=root mode=0755
with_items
:
-
"
{{
COMMON_DATA_DIR
}}"
-
"
{{
COMMON_APP_DIR
}}"
-
"
{{
COMMON_BIN_DIR
}}"
-
"
{{
COMMON_CFG_DIR
}}"
user
:
name
:
"
{{
common_web_user
}}"
shell
:
/bin/false
# Determine if machine is provisioned via vagrant
# Some EC2-specific steps would need to be skipped
-
name
:
check if instance is vagrant
stat
:
path=/home/vagrant
stat
:
path
:
/home/vagrant
register
:
vagrant_home_dir
# Ensure that we get a current version of Git
# GitHub requires version 1.7.10 or later
# https://help.github.com/articles/https-cloning-errors
-
name
:
Add git apt repository
apt_repository
:
repo="{{ common_git_ppa }}"
apt_repository
:
repo
:
"
{{
common_git_ppa
}}"
-
name
:
Install role-independent useful system packages
# do this before log dir setup; rsyslog package guarantees syslog user present
apt
:
>
pkg={{','.join(common_debian_pkgs)}} install_recommends=yes
state=present update_cache=yes
apt
:
name
:
"
{{
item
}}"
install_recommends
:
yes
state
:
present
update_cache
:
yes
with_items
:
common_debian_pkgs
-
name
:
Create common log directory
file
:
>
path={{ COMMON_LOG_DIR }} state=directory owner=syslog
group=syslog mode=0755
-
name
:
Create common directories
file
:
path
:
"
{{
item.path
}}"
state
:
"
{{
item.state
|
default('directory')
}}"
owner
:
"
{{
item.owner
|
default('root')
}}"
group
:
"
{{
item.group
|
default('root')
}}"
mode
:
0755
with_items
:
common_directories
-
name
:
upload sudo config for key forwarding as root
copy
:
>
src=ssh_key_forward dest=/etc/sudoers.d/ssh_key_forward
validate='visudo -c -f %s' owner=root group=root mode=0440
copy
:
src
:
ssh_key_forward
dest
:
/etc/sudoers.d/ssh_key_forward
validate
:
'
visudo
-c
-f
%s'
owner
:
root
group
:
root
mode
:
0440
-
name
:
pip install virtualenv
pip
:
>
name="{{ item }}" state=present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
pip
:
name
:
"
{{
item
}}"
state
:
present
extra_args
:
"
-i
{{
COMMON_PYPI_MIRROR_URL
}}"
with_items
:
common_pip_pkgs
-
name
:
Install rsyslog configuration for edX
template
:
>
dest=/etc/rsyslog.d/99-edx.conf
src=edx_rsyslog.j2
owner=root group=root mode=644
notify
:
restart rsyslogd
-
name
:
Remove the default rsyslog configuration
file
:
path=/etc/rsyslog.d/50-default.conf
state=absent
notify
:
restart rsyslogd
# This is in common to keep all logrotation config
# in the same role
-
name
:
Create hourly subdirectory in logrotate.d
file
:
path=/etc/logrotate.d/hourly state=directory
-
name
:
Install logrotate configuration for edX
template
:
>
dest=/etc/logrotate.d/hourly/edx-services
src=etc/logrotate.d/hourly/edx_logrotate.j2
owner=root group=root mode=644
-
name
:
Install logrotate configuration for tracking file
template
:
>
dest=/etc/logrotate.d/hourly/tracking.log
src=etc/logrotate.d/hourly/edx_logrotate_tracking_log.j2
owner=root group=root mode=644
-
name
:
Add logrotate for tracking.log to cron.hourly
copy
:
>
dest=/etc/cron.hourly/logrotate
src=etc/cron.hourly/logrotate
owner=root group=root mode=555
-
name
:
update /etc/hosts
template
:
src=hosts.j2 dest=/etc/hosts
template
:
src
:
hosts.j2
dest
:
/etc/hosts
when
:
COMMON_HOSTNAME|length > 0
register
:
etc_hosts
-
name
:
update /etc/hostname
template
:
src=hostname.j2 dest=/etc/hostname
template
:
src
:
hostname.j2
dest
:
/etc/hostname
when
:
COMMON_HOSTNAME|length > 0
register
:
etc_hostname
-
name
:
run hostname
shell
:
>
hostname -F /etc/hostname
shell
:
hostname -F /etc/hostname
when
:
COMMON_HOSTNAME|length >0 and (etc_hosts.changed or etc_hostname.changed)
-
name
:
update /etc/dhcp/dhclient.conf
template
:
src=etc/dhcp/dhclient.conf.j2 dest=/etc/dhcp/dhclient.conf
template
:
src
:
etc/dhcp/dhclient.conf.j2
dest
:
/etc/dhcp/dhclient.conf
when
:
COMMON_CUSTOM_DHCLIENT_CONFIG
-
name
:
add ssh-warning banner motd
template
:
>
dest=/etc/motd.tail
src={{ COMMON_MOTD_TEMPLATE }} mode=0755 owner=root group=root
-
name
:
update ssh config
template
:
>
dest=/etc/ssh/sshd_config
src=sshd_config.j2 mode=0644 owner=root group=root
notify
:
restart ssh
-
name
:
Copy the templates to their respestive destination
template
:
dest
:
"
{{
item.dest
}}"
src
:
"
{{
item.src
}}"
owner
:
root
group
:
root
mode
:
"
{{
item.mode
|
default(644)
}}"
with_items
:
-
{
src
:
'
edx_rsyslog.j2'
,
dest
:
'
/etc/rsyslog.d/99-edx.conf'
}
-
{
src
:
'
etc/logrotate.d/hourly/edx_logrotate.j2'
,
dest
:
'
/etc/logrotate.d/hourly/edx-services'
}
-
{
src
:
'
etc/cron.hourly/logrotate.j2'
,
dest
:
'
/etc/cron.hourly/logrotate'
,
mode
:
'
555'
}
-
{
src
:
'
etc/logrotate.d/hourly/edx_logrotate_tracking_log.j2'
,
dest
:
'
/etc/logrotate.d/hourly/tracking.log'
}
-
{
src
:
'
{{
COMMON_MOTD_TEMPLATE
}}'
,
dest
:
'
/etc/motd.tail'
,
mode
:
'
755'
}
-
{
src
:
'
sshd_config.j2'
,
dest
:
'
/etc/ssh/sshd_config'
}
notify
:
-
restart ssh
-
restart rsyslogd
\ No newline at end of file
playbooks/roles/common/
files/etc/cron.hourly/logrotate
→
playbooks/roles/common/
templates/etc/cron.hourly/logrotate.j2
View file @
c3a58c5c
File moved
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