Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37063

Run ansible as another user on jenkins server

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • 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

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

              Created:
              Updated: