Run ansible as another user on jenkins server

XMLWordPrintable

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: ansible-plugin
    • None

      Could you improve support of sudo directly on jenkins server, please?
      For example: If you are running jenkins under jenkinsuser and if you want to run ansible as another user, there is no way to accomplish that.
      Solution would be add arbitrary string before ansible executable in ansible plugin and edit sudoers like >

      /etc/sudoers
      jenkinsuser ALL=(anotheruser)NOPASSWD:/usr/bin/ansible-playbook /tmp/* -i /tmp/* * --private-key /home/anotheruser/.ssh/id_rsa_ansible *

      final command would be
      sudo -u anotheruser-i /bin/bash -l -c '/usr/bin/ansible-playbook /tmp/playbook.yml -i /tmp/inventory -f 5 --private-key /home/anotheruser/.ssh/id_rsa_ansible -vvvv'

      Thanks

            Assignee:
            Acien1951 Acien1951
            Reporter:
            Acien1951 Acien1951
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: