aboutsummaryrefslogtreecommitdiffstats
path: root/roles/mediagoblin/tasks/mediagoblin.yml
blob: b7df031d1c51a3b2117006dba7a2f2e59e956466 (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
- name: Install mediagoblin dependencies
  apt: name={{item}} state=installed
  with_items:
    - python3-dev
    - python3-lxml
    - python3-pil
    - python3-virtualenv
    - python3-babel
    - 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=0750
        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: Create virtualenv
  shell: 
    virtualenv --python=python3 --system-site-packages . 
    chdir="{{mediagoblin_basedir}}/src"
    creates="{{mediagoblin_basedir}}/src/bin/python"
  sudo: yes
  sudo_user: "{{ 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 flup in virtualenv
  easy_install: 
    name=flup
    virtualenv="{{ 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=/srv/mediagoblin/src/mediagoblin_local.ini

- name: Copy mediagoblin paste config
  template: src=paste_local.ini.j2
            dest=/srv/mediagoblin/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

# XXX: TODO: how to create a systemd unit?

- 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?