Tag: Google Compute Engine

  • Run `sudo` with Ansible `become` Option on Google Compute Engine

    Playbook config:

    - name: basic setup
      hosts: default
      user: user
      become: true
      become_user: root
      become_method: sudo
      roles:
        - tasks
    

    If you got the following errors:

    GATHERING FACTS *************************************************************** 
    failed: [server1] => {"failed": true, "parsed": false}
    OpenSSH_6.9p1, LibreSSL 2.1.8
    debug1: Reading configuration data /Users/user/.ssh/config
    debug1: /Users/user/.ssh/config line 139: Applying options for server1
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 21: Applying options for *
    debug1: auto-mux: Trying existing master
    debug1: mux_client_request_session: master session id: 2
    sudo: sorry, you must have a tty to run sudo
    

    Then visudo and disable requiretty:

    Defaults    !requiretty