now let's see whether we can get the logging working now

Merge branch 'nosudo_celery' into log_warnings
pull/1/head
Raymond Yee 2016-06-23 13:54:50 -07:00
commit 73d107afa4
3 changed files with 68 additions and 41 deletions

View File

@ -21,4 +21,4 @@
#
# m h dom mon dow command
* * * * * cd /opt/regluit; . /opt/regluit/ENV/bin/activate; /opt/regluit/ENV/bin/django-admin.py emit_notices --settings=regluit.settings.please > /opt/regluit/deploy/emit_notices.log 2>&1 ; touch /opt/regluit/deploy/last-cron
@reboot sudo mkdir /var/run/celery; sudo chown celery:celery /var/log/celery /var/run/celery; sudo /etc/init.d/celeryd restart; sudo /etc/init.d/celerybeat restart;
@reboot sudo mkdir /var/run/celery; sudo chown celery:celery /var/log/celery /var/run/celery; cd /opt/regluit; . /opt/regluit/ENV/bin/activate; /opt/regluit/ENV/bin/django-admin.py celeryd_multi restart w1 --settings=regluit.settings.please; /etc/init.d/celerybeat restart;

3
vagrant/Vagrantfile vendored
View File

@ -30,8 +30,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
"-e class=please",
"-e hostname=please.unglue.it",
"-e setdns=true",
"-e branch=log_warnings"
]
"-e branch=log_warnings" ]
end

View File

@ -204,9 +204,11 @@
- name: establish regluit.pth
lineinfile: create=yes dest=/opt/regluit/ENV/lib/python2.7/site-packages/regluit.pth line="/opt/regluit/"
sudo: no
- name: establish opt.pth
lineinfile: create=yes dest=/opt/regluit/ENV/lib/python2.7/site-packages/regluit.pth line="/opt/"
sudo: no
#sudo('mkdir /var/www/static')
#sudo('chown ubuntu:ubuntu /var/www/static')
@ -316,6 +318,7 @@
lineinfile: create=yes dest=/opt/regluit/settings/local.py line="SECRET_KEY=u'{{django_secret_key}}'"
notify:
- restart apache2
sudo: no
#
#sudo ("/etc/init.d/apache2 restart")
@ -331,10 +334,10 @@
- name: enable ufw
ufw: state=enabled
#with cd("/opt/regluit"):
#
# sudo ("yes | adduser --no-create-home celery --disabled-password --disabled-login")
# create celery user and group
# also put {{user}} into celery group
- name: make celery group
group: name=celery
@ -345,66 +348,90 @@
group=celery
generate_ssh_key=no
# sudo ("cp deploy/celeryd /etc/init.d/celeryd")
# sudo ("chmod 755 /etc/init.d/celeryd")
- name: copy deploy/celeryd
- name: add {{user}} to celery group
user: name={{user}} groups=celery append=yes
# create directories for celery
# /var/log/celery and /var/run/celery
- name: create /var/log/celery
file: path=/var/log/celery state=directory owner=celery group=celery mode=0775
- name: create /var/run/celery
file: path=/var/run/celery state=directory owner=celery group=celery mode=0775
# set up celeryd
- name: set up /etc/init.d/celeryd (from deploy/celeryd)
command: cp /opt/regluit/deploy/celeryd /etc/init.d/celeryd
# still need?
- name: set mode on /etc/init.d/celeryd
file: path=/etc/init.d/celeryd mode=0755
# sudo ("cp deploy/celeryd.conf /etc/default/celeryd")
- name: copy deploy/celeryd.conf
command: cp "/opt/regluit/deploy/celeryd_{{class}}.conf" /etc/default/celeryd
- name: set mode on /etc/default/celeryd
file: path=/etc/default/celeryd mode=0644
# sudo ("mkdir /var/log/celery")
- name: make /var/log/celery
file: path=/var/log/celery state=directory owner=celery group=celery mode=0755
# sudo ("mkdir /var/run/celery")
# sudo ("chown celery:celery /var/log/celery /var/run/celery")
- name: make /var/run/celery
file: path=/var/run/celery state=directory owner=celery group=celery mode=0755
file: path=/etc/default/celeryd mode=0644
# - name: just before launching celeryd
# pause: prompt='Press return to continue. Press Ctrl+c and then "a" to abort'
# start up celeryd
# sudo ("/etc/init.d/celeryd start")
- name: start celeryd
command: /etc/init.d/celeryd start
# old way with root
# - name: start celeryd
# command: /etc/init.d/celeryd start
# - name: start celery queue with celery multi
# command: /opt/regluit/ENV/bin/django-admin.py celeryd_multi restart w1
# sudo: no
- name: celeryd_multi
django_manage: >
command="celeryd_multi restart w1"
app_path=/opt/regluit/
settings="regluit.settings.{{class}}"
virtualenv=/opt/regluit/ENV
sudo: no
# - name: just after attempt to launch celeryd
# pause: prompt='Press return to continue. Press Ctrl+c and then "a" to abort'
# sudo ("cp deploy/celerybeat /etc/init.d/celerybeat")
# sudo ("chmod 755 /etc/init.d/celerybeat")
# https://stackoverflow.com/questions/24162996/how-to-move-rename-a-file-using-an-ansible-task-on-a-remote-system
# set up celerybeat
- name: copy deploy/celerybeat
command: cp /opt/regluit/deploy/celerybeat /etc/init.d/celerybeat
- name: set mode on /etc/init.d/celerybeat
file: path=/etc/init.d/celerybeat mode=0755
file: path=/etc/init.d/celerybeat mode=0775
# sudo ("cp deploy/celerybeat.conf /etc/default/celerybeat")
- name: copy deploy/celerybeat,conf
- name: copy deploy/celerybeat,conf to /etc/default/celerybeat
command: cp "/opt/regluit/deploy/celerybeat_{{class}}.conf" /etc/default/celerybeat
- name: set mode on /etc/default/celerybeat
file: path=/etc/default/celerybeat mode=0755
# sudo ("mkdir /var/log/celerybeat")
# sudo ("chown celery:celery /var/log/celerybeat")
- name: make /var/log/celerybeat
file: path=/var/log/celerybeat state=directory owner=celery group=celery mode=0755
- name: set mode on /etc/default/celerybeat
file: path=/etc/default/celerybeat mode=0775
# sudo ("/etc/init.d/celerybeat start")
- name: create /var/log/celerybeat
file: path=/var/log/celerybeat state=directory owner=celery group=celery mode=0775
# - name: just before launching celerybeat
# pause: prompt='Press return to continue. Press Ctrl+c and then "a" to abort'
- name: start celerybeat
command: /etc/init.d/celerybeat start
sudo: no
# - name: just after attempt to launch celerybeat
# pause: prompt='Press return to continue. Press Ctrl+c and then "a" to abort'
# run data loading script
- name: run data loading script
script: "load_data_{{class}}.sh"
@ -413,6 +440,7 @@
# set up crontab
- name: crontab
command: crontab "/opt/regluit/deploy/crontab_{{class}}.txt"
sudo: no
- name: add ssh keys from /opt/regluit/deploy/public_keys/
authorized_key: user={{user}} key={{ lookup('file', item) }} state=present