Skip to content

Commit

Permalink
Merge branch 'fix/issue-62'. Merge #79.
Browse files Browse the repository at this point in the history
  • Loading branch information
ypid committed Jan 17, 2017
2 parents d7b604d + 326a9ab commit e6f9ea3
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 39 deletions.
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ Added

- Add support for the `Apache HTTP Server`_, founded by https://www.hamcos.de/. [ypid_]

- Add Ansible tags for env roles. To only prepare the ownCloud role
environment, you can use the ``role::owncloud:env`` tag. [ypid_]

- Provide various configuration options from the :file:`config.php` file using
Ansible facts. [ypid_]

Changed
~~~~~~~

Expand Down Expand Up @@ -63,6 +69,13 @@ Fixed
generation. ``groups`` is not a list of the groups of the current host but a
dictionary of all groups. Use ``group_names``. [ypid_]

- Don’t attempt to run certain :command:`occ` subcommands when ownCloud is in
maintenance mode as some subcommands are not available in maintenance mode.
This kind of restricts the use of the maintenance mode for this role when you
want to use those :command:`occ` subcommands.
As a result, this role does not enable or disable maintenance mode and
the role maintainers recommend to leave maintainers mode disabled. [ypid_]

Security
~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ debops.owncloud - Install and manage ownCloud instances

Copyright (C) 2015-2016 Maciej Delmanowski <[email protected]>
Copyright (C) 2015 Hartmut Goebel <[email protected]>
Copyright (C) 2015-2016 Robin Schneider <[email protected]>
Copyright (C) 2015-2016 DebOps https://debops.org/
Copyright (C) 2015-2017 Robin Schneider <[email protected]>
Copyright (C) 2015-2017 DebOps https://debops.org/

This Ansible role is part of DebOps.

Expand Down
6 changes: 3 additions & 3 deletions docs/playbooks/owncloud-apache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
roles:

- role: debops.apache/env
tags: [ 'role::apache' ]
tags: [ 'role::apache', 'role::apache:env' ]

- role: debops.php/env
tags: [ 'role::php', 'role::apt_preferences', 'role::logrotate' ]
tags: [ 'role::php', 'role::php:env','role::apt_preferences', 'role::logrotate' ]

- role: debops.owncloud/env
tags: [ 'role::owncloud' ]
tags: [ 'role::owncloud', 'role::owncloud:env' ]

- role: debops.apt_preferences
tags: [ 'role::apt_preferences' ]
Expand Down
4 changes: 2 additions & 2 deletions docs/playbooks/owncloud-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
roles:

- role: debops.php/env
tags: [ 'role::php', 'role::apt_preferences', 'role::logrotate' ]
tags: [ 'role::php', 'role::php:env','role::apt_preferences', 'role::logrotate' ]

- role: debops.owncloud/env
tags: [ 'role::owncloud', 'role::nginx' ]
tags: [ 'role::owncloud', 'role::owncloud:env', 'role::nginx' ]

- role: debops.apt_preferences
tags: [ 'role::apt_preferences' ]
Expand Down
24 changes: 24 additions & 0 deletions env/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,27 @@
group: 'root'
mode: '0700'
when: (owncloud__nginx_client_body_temp_path != "")

# Ansible local facts [[[

- name: Make sure that Ansible local facts directory is present
file:
path: '/etc/ansible/facts.d'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0755'

- name: Save ownCloud local facts
template:
src: 'etc/ansible/facts.d/owncloud.fact.j2'
dest: '/etc/ansible/facts.d/owncloud.fact'
owner: 'root'
group: 'root'
mode: '0755'
register: owncloud__register_local_facts

- name: Gather facts if they were modified
action: setup
when: owncloud__register_local_facts|changed
# ]]]
1 change: 1 addition & 0 deletions env/templates
24 changes: 0 additions & 24 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,3 @@

- include: 'copy.yml'
tags: [ 'role::owncloud:copy' ]

# Ansible local facts [[[

- name: Make sure that Ansible local facts directory is present
file:
path: '/etc/ansible/facts.d'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0755'

- name: Save ownCloud local facts
template:
src: 'etc/ansible/facts.d/owncloud.fact.j2'
dest: '/etc/ansible/facts.d/owncloud.fact'
owner: 'root'
group: 'root'
mode: '0644'
register: owncloud__register_local_facts

- name: Gather facts if they were modified
action: setup
when: owncloud__register_local_facts|changed
# ]]]
15 changes: 14 additions & 1 deletion tasks/run_occ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@
no_log: True
register: owncloud__occ_run
become_user: '{{ owncloud__user }}'
when: owncloud__occ_item|d() and owncloud__occ_item.command|d("") != "" and (owncloud__occ_item.when|d(True) | bool)
## https://github.com/debops/ansible-owncloud/issues/62
when: (owncloud__occ_item|d() and
owncloud__occ_item.command|d("") != "" and
(owncloud__occ_item.when|d(True) | bool) and not (
ansible_local|d() and ansible_local.owncloud|d() and
ansible_local.owncloud.maintenance|d() | bool and (
owncloud__occ_item.command.startswith("dav") or
owncloud__occ_item.command.startswith("federation") or
owncloud__occ_item.command.startswith("files") or
owncloud__occ_item.command.startswith("trashbin") or
owncloud__occ_item.command.startswith("versions")
)
)
)

# - name: Debug occ command
# debug:
Expand Down
45 changes: 38 additions & 7 deletions templates/etc/ansible/facts.d/owncloud.fact.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
{{ ({
"enabled": "true",
"webserver": owncloud__webserver|string,
"release": owncloud__release|string,
"variant": owncloud__variant|string,
"auto_security_updates_enabled": owncloud__auto_security_updates_enabled|bool,
}) | to_nice_json }}
#!/usr/bin/env python

# {{ ansible_managed }}

from __future__ import print_function
import os
from json import loads, dumps
import subprocess

output = loads('''{{ ({
"enabled": (owncloud__deploy_state == "present"),
"webserver": owncloud__webserver|string,
"variant": owncloud__variant|string,
"auto_security_updates_enabled": owncloud__auto_security_updates_enabled|bool,
}) | to_nice_json }}''')


if os.path.isfile('/var/www/owncloud/config/config.php'):
try:
config_cmd = subprocess.Popen(
['php', '-r', 'include "/var/www/owncloud/config/config.php"; echo json_encode($CONFIG);'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
except:
pass
else:
std_out, std_err = config_cmd.communicate()

if config_cmd.returncode == 0 and len(std_err) == 0:
config = loads(std_out)
for key in ['instanceid', 'version', 'updatechecker', 'theme', 'maintenance', 'datadirectory', 'trusted_domains']:
output[key] = config[key]

if 'version' in output:
output['release'] = '.'.join(output['version'].split('.')[:2])

print(dumps(output, sort_keys=True, indent=2))

0 comments on commit e6f9ea3

Please sign in to comment.