Ansible Git Module - Private Key Not Found

By Tyler on

Ansible’s git module fails when given a relative path for key_file. The realpath jinga2 filter solves this problem.

- name: Deploy using Git over SSH
  git: repo=ssh:[email protected]/foo.git
       key_file={{ "ssh_keys/id_rsa" | realpath }}

VMWare Shared Folder Set Ownership

By Tyler on

The problem with VMWare shared folders is that you can’t specify the owner/group so the default ends up being root for both. This isn’t ideal, for instance, if we’re sharing web files that need to be owned by Apache in order to be served. Piggybacking off a comment from this post, here’s how to specify the owner/group of a shared folder:

  1. Ensure VMWare Tools is installed.
  2. Execute:
    sudo echo ".host:/ /mnt/hgfs vmhgfs rw,uid=33,gid=33" >> /etc/fstab
    sudo umount /mnt/hgfs
    sudo mount /mnt/hgfs

What this does is append /etc/fstab to specify how /mnt/hgfs should be mounted in terms of ownership. uid and gid 33 is Apache’s www-data user on Debian-based distrobutions. /mnt/hgfs is then re-mounted with new ownership.

Postgres Run Query on Multiple Tables

By Tyler on

If a query needs to be run on multiple tables with similar schemas, use this anonymous code block to reduce repetition.

DO $$
  current_table text;
    FOREACH current_table IN ARRAY ARRAY['table1', 'table2']
        EXECUTE format('DELETE FROM %I WHERE foo = %L', current_table, 'bar');
END $$;