aboutsummaryrefslogtreecommitdiffstats
path: root/roles/mediagoblin/tasks/mediagoblin.yml
blob: ff092e62403fb1fd46c806b6401f4b439348d551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
- name: Install mediagoblin dependencies
  apt: name={{item}} state=installed
  with_items:
    - python3-dev
    - python3-lxml
    - python3-pil
    - python3-virtualenv
    - python3-babel
    - python3-pip
    - virtualenv
    - automake
    - npm           # XXX: really? UGH
    - nodejs-legacy
  tags:
    - dependencies

- name: Create mediagoblin user
  user: name={{ mediagoblin_user }}
        createhome=yes
        groups=www-data
        system=yes
        home=/var/lib/mediagoblin
        state=present

- name: Create mediagoblin base directory
  file: name={{ mediagoblin_basedir }}
        state=directory
        owner={{ mediagoblin_user }}

- name: Create user data directory
  file: name={{ mediagoblin_basedir }}/data
        state=directory
        mode=0755
        owner={{ mediagoblin_user }}

- name: Create mediagoblin PID directory
  file: name=/run/mediagoblin
        state=directory
        owner={{ mediagoblin_user }}

- name: Create mediagoblin logs directory
  file: name=/var/log/mediagoblin
        state=directory
        owner={{ mediagoblin_user }}

- name: Checkout git
  git: repo={{ mediagoblin_git_uri }}
       dest={{ mediagoblin_basedir }}/src
       version={{ mediagoblin_git_ref }}
       recursive=yes
       accept_hostkey=yes
  sudo: yes
  sudo_user: "{{ mediagoblin_user }}"

- name: Create mediagoblin user_dev directory
  file: name={{ mediagoblin_basedir }}/src/user_dev
        state=directory
        owner={{ mediagoblin_user }}

- name: Build mediagoblin
  shell:
    ./bootstrap.sh && ./configure -with-python3 && make
    chdir="{{mediagoblin_basedir }}/src"
    creates="{{mediagoblin_basedir}}/src/mediagoblin.egg-info"
  sudo: yes
  sudo_user: "{{ mediagoblin_user }}"

- name: Install flup6 in virtualenv
  shell: "{{ mediagoblin_basedir }}/src/bin/pip install flup6"
  args:
    chdir="{{ mediagoblin_basedir }}"/src
  sudo: yes
  sudo_user: "{{ mediagoblin_user }}"

- name: Update DB
  shell:
    ./bin/gmg dbupdate
    chdir="{{ mediagoblin_basedir }}/src"
  sudo: yes
  sudo_user: "{{ mediagoblin_user }}"

- name: Copy mediagoblin config
  template: src=mediagoblin_local.ini.j2
            dest={{ mediagoblin_basedir}}/src/mediagoblin_local.ini

- name: Copy mediagoblin paste config
  template: src=paste_local.ini.j2
            dest={{ mediagoblin_basedir }}/src/paste_local.ini

- name: Copy generic mediagoblin nginx site configuration
  template: src=etc_nginx_sites-available_mediagoblin.j2
            dest=/etc/nginx/sites-available/mediagoblin

- name: Copy generic mediagoblin celeryd systemd file
  template: src=etc_systemd_system_mediagoblin-celeryd.service.j2
            dest=/etc/systemd/system/mediagoblin-celeryd.service

- name: Copy generic mediagoblin paster systemd file
  template: src=etc_systemd_system_mediagoblin-paster.service.j2
            dest=/etc/systemd/system/mediagoblin-paster.service

- name: Have systemd detect new files
  shell: systemctl daemon-reload

- name: (Re)start systemd paster service
  shell: systemctl restart mediagoblin-celeryd.service && systemctl restart mediagoblin-paster.service

- name: Enable systemd services
  shell: systemctl enable mediagoblin-celeryd.service && systemctl enable mediagoblin-paster.service

- name: Create nginx symlink for default
  file: state=link
        src=/etc/nginx/sites-available/mediagoblin
        dest=/etc/nginx/sites-enabled/mediagoblin
  notify: nginx restart     # reload not sufficient?