Skip to content

[no refs]: conflicts with 'become' and 'delegate_to' methods #30

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

Merged

Conversation

motoreagattoimburrato
Copy link
Contributor

Users may not be the same on controller and remote nodes.
So, if you don't have the same of it, you may run into errors like the follow:

fatal: [default]: FAILED! => {
    "changed": false,
    "module_stderr": "Sorry, try again.\n[sudo via ansible, key=random_casual_miao] password:\nsudo: 1 incorrect password attempt\n",",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

The commit solves this problem and can be considered as a patch level

…an't be the same on controller and remote nodes
@MonolithProjects
Copy link
Owner

Hi there. I guess the better solution would be to add become: false to the tasks with delegate_to: localhost. Basically there is no need to escalate the privileges.

@motoreagattoimburrato
Copy link
Contributor Author

For example, image to run a playbook on a workstation that need privileges to launch some commands: if you set become: false, the playbook may fails.
I tell you this because I have such a situation, but feel free to evaluate the commit as you see fit.

@motoreagattoimburrato
Copy link
Contributor Author

Also, I think it's better run all tasks on remote: in this case, I see no reason to use the delegate_to method.

@MonolithProjects
Copy link
Owner

Even if the playbook is running with escalated privileges, you can set specific task to not to use sudo. I mean the solution could look like this:

- name: Download runner package version - "{{ runner_version }}" (RUN ONCE)
  get_url:
    url: "https://github.com/actions/runner/releases/download/v{{ runner_version }}/actions-runner-linux-x64-{{ runner_version }}.tar.gz"
    dest: "./actions-runner-linux-{{ runner_version }}.tar.gz"
    force: no
  run_once: yes
  become: false
  delegate_to: localhost
  tags:
    - install

For the delegate_to, well the idea behind this was to not to download the package from the internet 10 times if you have 10 runners. Rather the package is downloaded once to the local host and distributed to the remote hosts from there. But yah maybe it is adding some additional overhead to the whole role and i may change it in the future.

@motoreagattoimburrato
Copy link
Contributor Author

I understand, so I'll try with become: false

@motoreagattoimburrato
Copy link
Contributor Author

It's work!

@motoreagattoimburrato
Copy link
Contributor Author

sorry for all these "force-pushed", typing errors as you can see

@MonolithProjects MonolithProjects merged commit ce28dd6 into MonolithProjects:master Oct 22, 2020
@MonolithProjects
Copy link
Owner

No problem at all. Thanks for your help. The new release 1.2.6 with your fix is already in the Ansible Galaxy

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