Skip to content

Add support to the make module for targets with options - #18848

Closed
stevekuznetsov wants to merge 1 commit into
ansible:develfrom
stevekuznetsov:skuznets/make
Closed

stevekuznetsov wants to merge 1 commit into
ansible:develfrom
stevekuznetsov:skuznets/make

Conversation

@stevekuznetsov

Copy link
Copy Markdown
Contributor
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

make

ANSIBLE VERSION
$ ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
SUMMARY

In order to run a make target with options, we need to not
assume that the target that is passed in to the module is to
be interpreted as one command-line argument. This allows us
to support targets with options like:
$ make some-target -o some-file

Where the some-target target skips rebuilding some-file
even if the file is old. Currently, the implementation would
attempt to run the some-target -o some-file target, which
does not exist.

make does not allow for targets with spaces in their names,
so we should be safe to break up the command-line arguments
like this and not risk mutilating a valid target name.

Signed-off-by: Steve Kuznetsov [email protected]

BEFORE
TASK [make : execute make target(s) "test -o build" in the origin-web-console repository] ***
failed: [openshiftdevel] (item=test -o build) => {
    "cmd": "/bin/make 'test -o build'", 
    "failed": true, 
    "invocation": {
        "module_args": {
            "chdir": "/data/src/github.com/openshift/origin-web-console", 
            "params": null, 
            "target": "test -o build"
        }, 
        "module_name": "make"
    }, 
    "item": "test -o build", 
    "msg": "make: *** No rule to make target 'test -o build'.  Stop.", 
    "rc": 2, 
    "stderr": "make: *** No rule to make target 'test -o build'.  Stop.\n", 
    "stdout": "", 
    "stdout_lines": []
}
AFTER
TASK [make : execute make target(s) "test -o build" in the origin-web-console repository] ***
failed: [openshiftdevel] (item=test -o build) => {
    "cmd": "/bin/make test -o build", 
    "failed": true, 
    "invocation": {
        "module_args": {
            "chdir": "/data/src/github.com/openshift/origin-web-console", 
            "params": null, 
            "target": "test -o build"
        }, 
        "module_name": "make"
    }, 
    "item": "test -o build", 
    "msg": "<snip>make: *** [test] Error 3", 
    "rc": 2, 
    "stderr": "<snip>make: *** [test] Error 3\n", 
    "stdout": "<snip>Makefile:45: recipe for target 'test' failed\n", 
    "stdout_lines": [
        <snip>
        "Makefile:45: recipe for target 'test' failed"
    ]
}

(example after has a failed make target, but it runs correctly, just that example failed in the middle of the run)

@LinusU @gregdek I've added the version comment in the documentation.

Comment thread lib/ansible/modules/system/make.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ansible 3.2? we are not there yet 😂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll blame that one on dyslexia :)

In order to run a `make` target with options, we need to not
assume that the target that is passed in to the module is to
be interpreted as one command-line argument. This allows us
to support targets with options like:
  $ make some-target -o some-file

Where the `some-target` target skips rebuilding `some-file`
even if the file is old. Currently, the implementation would
attempt to run the `some-target -o some-file` target, which
does not exist.

`make` does not allow for targets with spaces in their names,
so we should be safe to break up the command-line arguments
like this and not risk mutilating a valid target name.

Signed-off-by: Steve Kuznetsov <[email protected]>
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 feature_pull_request module This issue/PR relates to a module. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 13, 2016
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 20, 2016
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 2, 2017
@jimi-c jimi-c removed the plugin label Jan 4, 2017
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. community_review and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 5, 2017
@stevekuznetsov

Copy link
Copy Markdown
Contributor Author

@jimi-c do you know why this needs_revision?

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 11, 2017
@stevekuznetsov

Copy link
Copy Markdown
Contributor Author

Closing for inactivity ...

@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 4, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects_2.3 This issue/PR affects Ansible v2.3 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants