Last active
June 23, 2018 09:56
-
-
Save ihassin/7968371 to your computer and use it in GitHub Desktop.
Ansible user.yml playbook used in blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: webservers | |
user: vagrant | |
sudo: True | |
vars_files: | |
- vars.yml | |
vars: | |
deploy: deploy | |
home_dir: /home/deploy | |
tasks: | |
- 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/ita.pub 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/deploy_rsa.pub dest={{home_dir}}/.ssh/deploy_rsa.pub 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