Skip to content

Disable postgres and tar tasks when unused#26

Merged
raneq merged 5 commits intomasterfrom
disable-prostgres-when-unused
Jun 21, 2019
Merged

Disable postgres and tar tasks when unused#26
raneq merged 5 commits intomasterfrom
disable-prostgres-when-unused

Conversation

@raneq
Copy link
Collaborator

@raneq raneq commented Jun 20, 2019

This feature is needed for playbooks that don't have postgres install in the host (at least directly, not inside container), and still want to use this role.

If you modify the backups_role_script_prepare_template var, then it means that you are not using
this script template and therefore we don't need to create postgres roles, etc.
and you may not need sudoer permissions for tar. Therefore, we disable
the related tasks by default. However, if you still would like to enable those tasks,
set to true the corresponding variables:

  • backups_role_postgresql_enabled
  • backups_role_sudoers_enabled

Don't merge until #25 is merged. Otherwise it can overwrite some changes we did
Funny enough, I did it in the reverse order and I had no problem. ough...

raneq added 3 commits June 20, 2019 15:32
These tasks are only needed for the default backup prepare strategy. If you override it, you will probably want to use these 2 flags.
Know what? You can't self-reference variables in ansible.
This is why I created some_var and _some_var.
@raneq raneq requested a review from enricostano June 20, 2019 16:52
@raneq raneq added this to the v1.2.1 milestone Jun 20, 2019
# Otherwise, switch them off when the template has changed.
_backups_role_sudoers_enabled: "{{ backups_role_sudoers_enabled | default(_template_is_default) }}"
_backups_role_postgresql_enabled: "{{ backups_role_postgresql_enabled | default(_template_is_default) }}"

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could seem a bit of black magic. Why don't we just throw a warning or an error when we detect that the default template is not being used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't want to throw an error when the default template is not being used. We want it to be overridable, that's ok. But at the same time, we need this feature not to enforce postgres to be installed and .

An alternative to this "black magic" is to just give the flags and enforce to user of the role to set them to false (don't run postgres) if they use another script template to prepare the backups. But in my opinion, the default behavior should be a bit smarter than that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that including postgres tasks by default is a bit arbitrary since it just comes from what we started to backup.

I also would decouple sudoers and postgresql tasks, they shouldn't share the same meaning of "default".

I'm starting to think that this role should do nothing by default and that the user should enable the things that she needs to backup. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. I don't like the idea of assuming what users want to backup. By now I would just merge it, as we need it for opencell, but I would give it more time to think about it. Maybe placing one taskfile for postgres and one extra for tar? And then from the importer playbook "import tasks from" those taskfiles...

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, let's create a Trello card and an issue here in the repo and maybe a comment in the code. I think we should address this issue ASAP. Thanks!

@raneq raneq merged commit 2ff3cb4 into master Jun 21, 2019
@raneq raneq deleted the disable-prostgres-when-unused branch June 21, 2019 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants