aoh

A tool for running Ansible playbooks with `curl <url> | python` commands
git clone https://git.ashermorgan.net/aoh/
Log | Files | Refs | README

sudo_config.yml (597B)


      1 - name: probe for sudoers config path
      2   shell: visudo -c
      3   ignore_errors: true
      4   register: visudo_result
      5 
      6 - set_fact:
      7     sudoers_path: '{{ ((visudo_result.stdout ~ visudo_result.stderr) | regex_search("(/.*sudoers).*:", "\1"))[0] }}'
      8 
      9 - name: allow the user to use sudo {{"with no password" if test_user_allow_sudo == "nopasswd" else "with a password"}}
     10   copy:
     11     content: |
     12       {{ test_user_name }}  ALL=(ALL)  {{"NOPASSWD: " if test_user_allow_sudo == "nopasswd" else ""}} ALL
     13     mode: '0440'
     14     dest: '{{ sudoers_path ~ ".d/" ~ test_user_name }}'
     15   notify: delete test user sudoers file