-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/apache status, rework and improvments #8
Conversation
First should be the basics, followed by the advanced stuff.
s/apache__ref_vhosts_/apache__ref_vhost_/g
I will check the build error in a few days. Not yet sure about "RepresenterError: cannot represent an object:". If anyone has an idea. |
@ypid It seems to be an issue with Ansible, got another error like this in debops.bootstrap. |
{{ item.root_directives | indent(4) }} | ||
{% endif %} | ||
|
||
{{ debops__tpl_macros.indent(get_document_root_directives(item), 4) -}} | ||
</Directory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please double check that the closing directive is on a new line.
I've checked out 5e76849 and it produces the closing Directory on the same line, i.e. Require all granted</Directory>
. That makes apache unhappy: Expected </Directory> but saw </VirtualHost>\n"}
. That reminds me of https://github.com/debops/ansible-postfix/issues/80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I just double checked and it looks good. If it makes Apache unhappy by failing to (re)start it that is easy to catch. Harder would be if it would not complain but do the wrong thing. Luckily, a syntax check already tells the problem in this case. But I can see the potential problem.
apache2ctl -t
apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 19 of /etc/apache2/sites-enabled/debops.apache-status.conf: Expected </Location> but saw </VirtualHost>
Ah, right, this happens in the CI test. Damn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work. :-) Still some things I'd like to comment on.
CHANGES.rst
Outdated
~~~~~~~ | ||
|
||
- Change default virtual host server name from ``000-default`` to ``default.{{ | ||
apache__domain }}`` to increase the changes that a valid certificate is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "increase the chances"?
defaults/main.yml
Outdated
apache__domain: '{{ ansible_local.core.domain | ||
if (ansible_local|d() and ansible_local.core|d() and | ||
ansible_local.core.domain|d()) | ||
else ansible_domain }}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Although to be on the safe side (no debops.core
role present), I would finish this with:
else (ansible_domain if ansible_domain else ansible_hostname)
notify: [ 'Restart apache' ] | ||
# - name: Test apache and restart | ||
# command: apache2ctl configtest | ||
# notify: [ 'Restart apache' ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgotten debugging? I would leave unused handlers uncommented, they shouldn't affect the role. Commented out code looks weird, IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand but I don’t intent to release the role yet so I don’t mind that much. This is just to force me to edit this file and then I should notice the comment that I should also update the part of the docs which refers to this (as documented in this file as well). Thanks for the thoughtful review 👍
@@ -65,7 +38,7 @@ | |||
group: 'root' | |||
mode: '0644' | |||
when: (item.value.state|d("present") != "absent" and | |||
(item.value.type|d("default") not in ["divert"] or item.value.raw|d())) | |||
(item.value.type|d("default") not in ["divert", "dont-create"] or item.value.raw|d())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaning towards ignore
option for this case, see for example debops.cron
or debops.ifupdown
role. Seems to better mesh with present
and absent
. Perhaps a parameter name change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the ignore
and I agree with it, however, I already tried to name the option as good as possible and dont-create
does exactly what it says. With this, snippets can still be enabled and disabled, but the role does not try to create the template for them. This is why I thought making it explicit by this name is preferred. ignore
does not really hit the nail on the head in this case 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well.
f1faaa9
to
c90da65
Compare
c90da65
to
5f0bebb
Compare
@muelli All updated. Can you update your review? Thanks again! |
@@ -66,3 +96,13 @@ | |||
ansible_local.pki.gnutls_version|d()) | |||
else "0.0.0" }} | |||
{% endmacro %}{# ]]] #} | |||
|
|||
{% macro indent(content, width=4, indentfirst=False) %}{# [[[ #} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought: Would Jinja be interested in providing such a filter directly? Has there been a discussion, i.e. bug report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Done
Changed | ||
~~~~~~~ | ||
|
||
- Change default virtual host server name from ``000-default`` to ``default.{{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much does debops care about users who upgrade this role? E.g. should it be mentioned what the user has to do to get rid of old, unmaintained files? In this case, it seems that 000-default needs to be deleted manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah. no. sorry, I was confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before you delete any files, check if they are configuration files included in a package:
dpkg-query -s apache2
dpkg -S /etc/apache2/sites-available/000-default
If so, you shouldn't remove them. This might hinder future upgrades, automated or not. Instead, you should divert the affected files either in the same directory with a different suffix (usually .dpkg-divert
) or to another directory altogether so that the package manager still knows that they exist and can perform the package upgrades correctly.
This is different with the configuration files generated on the package installation dynamically, or managed by the ucf
system. In this case, you should check the postinstall script of a given package for some clues how to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not change the filename and thus does not leave unmaintained files danging around. But to your question, sure, something like this would be noted if it can not be avoided (which would be preferred obviously). But this does not necessarily apply to a unreleased role but thanks for checking back 😉
Ref: debops/docs#160
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drybjed The role already takes care of this 😉
@muelli Does it work for you now? |
yeah, it seems to work :) |
You mean to stop using macros and do it using multiple templates? I don’t think that would be a good idea in terms of maintainability. I don’t like the way some older DebOps roles handle this. All that redundancy 😉 |
@muelli Can you update your GitHub review? |
ah. hm. how do I do that? |
https://github.com/debops/ansible-apache/pull/8/files → "Review changes" |
Thanks guys, merged. |
@drybjed A short peek is probably enough. I did some more crazy (not too crazy actually) Jinja2 temperating stuff which you might find interesting 😉
I can merge it the next few days after I looked over it myself again. No hurry.