---
- name: allow Apache to remotely connect to mysql
  seboolean: name=httpd_can_network_connect_db state=yes persistent=yes

- name: allow Apache to remotely connect to wiki
  seboolean: name=httpd_can_network_connect state=yes persistent=yes

- name: allow Apache to remotely connect to Memcached
  seboolean: name=httpd_can_network_memcache state=yes persistent=yes

- name: allow Apache to talk to the wiki uploads dir over nfs
  seboolean: name=httpd_use_nfs state=yes persistent=yes

- name: set sebooleans so apache can send emails
  action: seboolean name=httpd_can_sendmail state=yes persistent=yes

- name: install needed packages
  yum: pkg={{ item }} state=present
  with_items:
  - mediawiki119
  - mediawiki119-Cite
  - mediawiki119-Lockdown
  - mediawiki119-SpecialInterwiki
  - librsvg2
  - mediawiki119-HTTP302Found
  - mediawiki119-intersection
  - mediawiki119-RSS
  - mediawiki-FedoraBadges
  - php-zmq
  - php-pecl-uuid
  tags:
  - packages

- name: adding FAS auth
  template: src=Auth_FAS.php.j2 dest=/usr/share/mediawiki119/extensions/Auth_FAS.php owner=root group=root mode=775
  tags:
  - config

- name: adding fedmsg emit
  copy: src=fedmsg-emit.php dest=/usr/share/mediawiki119/extensions/fedmsg-emit.php owner=root group=root mode=775
  tags:
  - config

- name: creating attachments dir
  file: path=/mnt/web/attachments owner=apache group=root mode=755 state=directory

- name: startup apache
  service: name=httpd enabled=yes state=started

- name: Fedora branding
  copy: src=skins/ dest=/usr/share/mediawiki119/skins owner=root group=root mode=775
  tags:
  - config

- name: creating wiki dir
  file: path=/srv/web/{{wikiname}}-wiki owner=root group=root mode=755 state=directory

#- name: creating config dir
#  file: src=/usr/share/mediawiki119/config dest=/srv/web/{{wikiname}}/config owner=apache group=apache mode=755 state=directory

# This doesn't seem to exist anymore in upstream....
#- name: install utils
#  file: src=/usr/share/mediawiki119/install-utils.inc dest=/srv/web/{{wikiname}}-wiki/install-utils.inc state=link

- name: install localsettings
  template: src=LocalSettings.php.{{wikiname}}.j2 dest=/srv/web/{{wikiname}}-wiki/LocalSettings.php owner=apache group=apache mode=600 setype=httpd_sys_content_t
  notify: restart httpd

- name: httpd conf
  template: src=mediawiki-app.conf.j2 dest=/etc/httpd/conf.d/{{wikiname}}.conf
  notify: restart httpd

- name: linking index.php
  file: dest=/srv/web/{{wikiname}}-wiki/index.php src=/usr/share/mediawiki119/index.php state=link

- name: linkng api.php
  file: dest=/srv/web/{{wikiname}}-wiki/api.php src=/usr/share/mediawiki119/api.php state=link

- name: linking opensearch
  file: dest=/srv/web/{{wikiname}}-wiki/opensearch_desc.php src=/usr/share/mediawiki119/opensearch_desc.php state=link

- name: linking extensions
  file: dest=/srv/web/{{wikiname}}-wiki/extensions src=/usr/share/mediawiki119/extensions state=link

- name: linking includes
  file: dest=/srv/web/{{wikiname}}-wiki/includes src=/usr/share/mediawiki119/includes state=link

- name: linking languages
  file: dest=/srv/web/{{wikiname}}-wiki/languages src=/usr/share/mediawiki119/languages state=link

- name: linking maintenance
  file: dest=/srv/web/{{wikiname}}-wiki/maintenance src=/usr/share/mediawiki119/maintenance state=link

- name: linking serialized
  file: dest=/srv/web/{{wikiname}}-wiki/serialized src=/usr/share/mediawiki119/serialized state=link

- name: linking skins
  file: dest=/srv/web/{{wikiname}}-wiki/skins src=/usr/share/mediawiki119/skins state=link

- name: linking load
  file: dest=/srv/web/{{wikiname}}-wiki/load.php src=/usr/share/mediawiki119/load.php state=link

- name: linking resources
  file: dest=/srv/web/{{wikiname}}-wiki/resources src=/usr/share/mediawiki119/resources state=link
