Skip to content

Instantly share code, notes, and snippets.

Last active Jun 23, 2018
What would you like to do?
Ansible user.yml playbook used in blog post
- hosts: webservers
user: vagrant
sudo: True
- vars.yml
deploy: deploy
home_dir: /home/deploy
- name: create deploy user
user: name=deploy comment="deploy user" generate_ssh_key=yes ssh_key_bits=2048 state=present password={{password}} shell=/bin/bash
- name: copy my ssh key to the user's .ssh directory
action: template src=templates/ dest={{home_dir}}/.ssh/authorized_keys mode=0700 owner={{deploy}} group={{deploy}}
- name: copy known hosts to deploy user
action: template src=templates/known_hosts dest={{home_dir}}/.ssh/known_hosts owner={{deploy}} group={{deploy}}
- name: copy deploy private key to VM
action: template src=templates/deploy_rsa dest={{home_dir}}/.ssh/deploy_rsa owner={{deploy}} group={{deploy}}
- name: copy deploy public key to VM
action: template src=templates/ dest={{home_dir}}/.ssh/ owner={{deploy}} group={{deploy}} mode=0644
- name: copy ssh_config so that bitbucket will be accessed using the injected private key
action: template src=templates/ssh_config dest={{home_dir}}/.ssh/config owner={{deploy}} group={{deploy}}
- name: copy sudoers
action: template src=templates/sudoers dest=/etc/sudoers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment