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

Add the ability to specify an install_dir to the gem module #38195

Merged
merged 6 commits into from May 21, 2018

Conversation

acatton
Copy link
Contributor

@acatton acatton commented Apr 2, 2018

SUMMARY

Some system administrator want to separate some gem installation from the rest
of the system. A good example is gem install --install-dir /opt/fluentd fluentd.

This pull request allows users of the gem module in Ansible to specify a
directory where the gem is going to be installed.

In addition to the future, this adds partial tests for the module in question.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

module: packaging.languages.gem

ANSIBLE VERSION
ansible 2.6.0 (add-install-dir-to-gem 8e1c0ce4d6) last updated 2018/04/03 00:31:31 (GMT +200)
  config file = None
  configured module search path = ['<home>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = <localdev>/ansible/lib/ansible
  executable location = <localdev>/ansible/.ansible/bin/ansible
  python version = 3.6.4 (default, Mar 13 2018, 18:16:01) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]
ADDITIONAL INFORMATION

N/A

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Apr 2, 2018
@ansibot
Copy link
Contributor

ansibot commented Apr 2, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

test/units/modules/packaging/language/test_gem.py:35:5: E303 too many blank lines (2)

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/packaging/language/gem.py:0:0: E309 version_added for new option (install_dir) should be 2.6. Currently 0.0

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Apr 2, 2018
@acatton acatton force-pushed the add-install-dir-to-gem branch 5 times, most recently from 16ec583 to 1ade944 Compare April 4, 2018 23:51
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 4, 2018
@acatton
Copy link
Contributor Author

acatton commented Apr 4, 2018

I'm bumping this, because I fixed all the unit test, but the integration tests are failing. And I can't understand how this is related to my fix... Are the integration tests flaky, or is it me?

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. core_review In order to be merged, this PR must follow the core review workflow. labels Apr 4, 2018
@samdoran
Copy link
Contributor

samdoran commented Apr 5, 2018

Looks like the test failures are due to external repositories that are inaccessible. I'll restart the tests.

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Apr 5, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 5, 2018
@acatton
Copy link
Contributor Author

acatton commented Apr 5, 2018

It looks like it's working @samdoran . Thanks :) .

@@ -0,0 +1 @@
{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the .pytest_cache entries from this commit please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course I can.

This is embarrassing. I usually check what I commit, but not this time :( .

@@ -252,6 +272,8 @@ def main():
module.fail_json(msg="Cannot specify version when state=latest")
if module.params['gem_source'] and module.params['state'] == 'latest':
module.fail_json(msg="Cannot maintain state=latest when installing from local source")
if module.params['user_install'] and module.params['install_dir']:
module.fail_json(msg="install_dir requires user_install=false")
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than adding an explicit check, you could just set user_install and install_dir as mutually exclusive.

Copy link
Contributor Author

@acatton acatton Apr 7, 2018

Choose a reason for hiding this comment

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

Tell me if I'm wrong, but I'm not sure this is possible.

In order for this feature to work, the user MUST specify:

gem:
  user_install: no
  install_dir: /some/other/directory

The default of user_install being True.

Unless I'm mistaking, mutually_exclusive means that "the user CAN specify
one, but MUST NOT specify the other." However, here, the user MUST specify both.

If I'm right, there are two solutions:

  • Keep the current code (= the manual check)
  • Change the default of user_install to no, thus loosing backward compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you're correct. After more careful reading, I see what you're trying to accomplish. Changing the default would not be a good idea.

@ansibot ansibot removed the core_review In order to be merged, this PR must follow the core review workflow. label Apr 6, 2018
@samdoran
Copy link
Contributor

samdoran commented May 4, 2018

Could you also add tests for state: absent when using a custom install_dir?

@acatton
Copy link
Contributor Author

acatton commented May 10, 2018

@samdoran you're right. Good catch. I've made the changes you recommended ;) .

ready_for_review

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 10, 2018
@ansibot
Copy link
Contributor

ansibot commented May 15, 2018

The test ansible-test sanity --test no-tests-as-filters [explain] failed with 3 errors:

test/integration/targets/gem/tasks/main.yml:49:9: use `current_gems.stdout is search` instead of `current_gems.stdout | search`
test/integration/targets/gem/tasks/main.yml:65:9: use `not current_gems.stdout is search` instead of `not current_gems.stdout | search`
test/integration/targets/gem/tasks/main.yml:88:28: use `.path is search` instead of `.path | search`

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. ci_verified Changes made in this PR are causing tests to fail. labels May 15, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 15, 2018
@acatton
Copy link
Contributor Author

acatton commented May 16, 2018

Thanks @samdoran for adding the tests, and updating the README 👍 .

Do you know what are the next steps to get that merge into devel? I'm not to familiar with Ansible's contribution process.

@samdoran samdoran merged commit 39f9d3e into ansible:devel May 21, 2018
@samdoran
Copy link
Contributor

Merged to devel for inclusion in 2.6. Thank you!

achinthagunasekara pushed a commit to achinthagunasekara/ansible that referenced this pull request May 23, 2018
…38195)

* Add the ability to specify an install_dir to the gem module

* Add GEM_HOME when installing a non-global gem

* Add tests for custom gem path

* Fix sanity tests

* Add changelog entry

* Rebase and add tests for incorrect options

Co-authored by: Antoine Catton <devel@antoine.catton.fr>
jacum pushed a commit to jacum/ansible that referenced this pull request Jun 26, 2018
…38195)

* Add the ability to specify an install_dir to the gem module

* Add GEM_HOME when installing a non-global gem

* Add tests for custom gem path

* Fix sanity tests

* Add changelog entry

* Rebase and add tests for incorrect options

Co-authored by: Antoine Catton <devel@antoine.catton.fr>
ilicmilan pushed a commit to ilicmilan/ansible that referenced this pull request Nov 7, 2018
…38195)

* Add the ability to specify an install_dir to the gem module

* Add GEM_HOME when installing a non-global gem

* Add tests for custom gem path

* Fix sanity tests

* Add changelog entry

* Rebase and add tests for incorrect options

Co-authored by: Antoine Catton <devel@antoine.catton.fr>
@ansible ansible locked and limited conversation to collaborators May 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants