Giter Club home page Giter Club logo

Comments (9)

ahuffman avatar ahuffman commented on June 1, 2024 1

Should be live on Ansible Galaxy now as version 2.0.3 @soloradish @pjattke

from ansible-sudoers.

pjattke avatar pjattke commented on June 1, 2024 1

Can confirm that the version released on ansible-galaxy also works flawless. Thank you!

from ansible-sudoers.

pjattke avatar pjattke commented on June 1, 2024

I also faced the same issue – I think local sudo privileges are not needed anyway. I would be happy to see this change integrated into master. Would that be possible @ahuffman?

from ansible-sudoers.

ahuffman avatar ahuffman commented on June 1, 2024
  1. Would changing the default sudoers_backup_path to ~/sudoers_backups resolve the issue if we set become: False on this task? I believe we have the become in there because the backup path is relative to the local ansible control node playbook directory, and would require privilege to write there if running as a non-root user.

  2. Another solution we could add is a sudoer_backup_become var and you can configure as you wish.

Let me know what makes more sense, but I think I'm probably leaning towards option 2.

from ansible-sudoers.

ahuffman avatar ahuffman commented on June 1, 2024

@soloradish @pjattke can you test out https://github.com/ahuffman/ansible-sudoers/tree/sudoers_backup_become and let me know if this works for you?

from ansible-sudoers.

pjattke avatar pjattke commented on June 1, 2024

@ahuffman Thanks for looking into that! The solution that I have applied so far is simply setting become: False in the respective task that keeps failing (of course, on a local copy of your role):

 - name: "Ensure local backup directory exists"
   file:
     state: "directory"
     path: "{{ sudoers_backup_path }}"
     mode: "0755"
   delegate_to: "localhost"
   connection: "local"
+  become: False                    <<< added line
   when:
     - "sudoers_backup | bool"
     - "sudoers_backup_path != ''"

However, I can see that this makes things less flexible and thus I think that your proposed solution 2) would be better suited. I have tested the sudoers_backup_become branch. However, I get the following error message even though I have defined sudoer_backup_become: False:

fatal: [hostA]: FAILED! => {
    "msg": "failed to transfer file to /etc/sudoers /Users/patrick/git/<redacted>/ansible/backups/host123/sudoers-backups/host123/etc/sudoers:
             dd: failed to open '/etc/sudoers': Permission denied"
}

I think this is because you also use this variable to define become in the task named Backup sudoers file. On the remote, however, sudo permissions are always required to allow reading the sudoers file. Therefore, I think that the change in this line should be reverted.

I would be happy to test again after you made this change. Thanks a lot!

from ansible-sudoers.

ahuffman avatar ahuffman commented on June 1, 2024

@pjattke give it a shot now, restored the backup task (fetch module) to become: True.

from ansible-sudoers.

pjattke avatar pjattke commented on June 1, 2024

@ahuffman Works now — thanks a lot for fixing. Will this change also be available on ansible-galaxy?

from ansible-sudoers.

ahuffman avatar ahuffman commented on June 1, 2024

yes, going to get everything fixed up shortly. Thanks for validating for me.

from ansible-sudoers.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.