# Configure the box. This happens after the base initialization, but before
# the project is cloned or built.

- name: set hostname
  hostname: name={{hostname}}

- name: add loopback references to our domain in /etc/hosts
  lineinfile:
    dest=/etc/hosts
    state=present
    line="127.0.0.1 {{hostname}} {{app_fqdn}}"

- name: ensure github.com is a known host
  lineinfile:
    dest=/etc/ssh/ssh_known_hosts
    state=present
    create=yes
    regexp="^github\\.com"
    line="{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"

- name: ensure ssh agent socket environment variable persists when sudoing
  lineinfile:
    dest=/etc/sudoers
    state=present
    insertafter="^Defaults"
    line='Defaults\tenv_keep += "SSH_AUTH_SOCK"'
    validate="visudo -cf %s"

# Configure the box. This happens after the base initialization, but before
# the project is cloned or built.

- name: set hostname
  hostname: name={{hostname}}

- name: add loopback references to our domain in /etc/hosts
  lineinfile:
    dest=/etc/hosts
    state=present
    line="127.0.0.1 {{hostname}} {{app_fqdn}}"

- name: ensure github.com is a known host
  lineinfile:
    dest=/etc/ssh/ssh_known_hosts
    state=present
    create=yes
    regexp="^github\\.com"
    line="{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"

- name: ensure ssh agent socket environment variable persists when sudoing
  lineinfile:
    dest=/etc/sudoers
    state=present
    insertafter="^Defaults"
    line='Defaults\tenv_keep += "SSH_AUTH_SOCK"'
    validate="visudo -cf %s"

- name: allow passwordless sudo - development only!
  lineinfile:
    dest=/etc/sudoers
    state=present
    regexp="^%sudo"
    line="%sudo	ALL=(ALL:ALL) NOPASSWD:ALL"
    validate="visudo -cf %s"
  when: env == "development"

Allow passwordless sudo in development.
Allow passwordless sudo in development.
