Skip to content
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

Merged
merged 21 commits into from
Feb 11, 2017

Conversation

ypid
Copy link
Member

@ypid ypid commented Jan 9, 2017

@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.

@ypid
Copy link
Member Author

ypid commented Jan 9, 2017

I will check the build error in a few days. Not yet sure about "RepresenterError: cannot represent an object:". If anyone has an idea.

@drybjed
Copy link
Member

drybjed commented Jan 10, 2017

@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>
Copy link
Contributor

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

Copy link
Member Author

@ypid ypid Feb 7, 2017

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.

Copy link
Member

@drybjed drybjed left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "increase the chances"?

apache__domain: '{{ ansible_local.core.domain
if (ansible_local|d() and ansible_local.core|d() and
ansible_local.core.domain|d())
else ansible_domain }}'
Copy link
Member

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' ]
Copy link
Member

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.

Copy link
Member Author

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()))
Copy link
Member

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?

Copy link
Member Author

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 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well.

@ypid ypid force-pushed the feature/apache_status branch from f1faaa9 to c90da65 Compare February 7, 2017 18:58
@ypid ypid force-pushed the feature/apache_status branch from c90da65 to 5f0bebb Compare February 7, 2017 19:02
@ypid
Copy link
Member Author

ypid commented Feb 7, 2017

@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) %}{# [[[ #}
Copy link
Contributor

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?

Copy link
Member Author

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.{{
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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 😉

@ypid
Copy link
Member Author

ypid commented Feb 10, 2017

@muelli Does it work for you now?

@muelli
Copy link
Contributor

muelli commented Feb 10, 2017

yeah, it seems to work :)
I'm wondering though if it's possible to get rid of the template macro code by providing separate templates. But that can also be done later.

@ypid
Copy link
Member Author

ypid commented Feb 10, 2017

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 😉

@ypid
Copy link
Member Author

ypid commented Feb 11, 2017

@muelli Can you update your GitHub review?

@muelli
Copy link
Contributor

muelli commented Feb 11, 2017

ah. hm. how do I do that?

@ypid
Copy link
Member Author

ypid commented Feb 11, 2017

https://github.com/debops/ansible-apache/pull/8/files → "Review changes"

@ypid ypid merged commit 22d4718 into debops:master Feb 11, 2017
ypid added a commit that referenced this pull request Feb 11, 2017
@ypid
Copy link
Member Author

ypid commented Feb 11, 2017

Thanks guys, merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants