Skip to content

Instantly share code, notes, and snippets.

@ysolis
Created May 6, 2016 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysolis/3ff6a2b89b7e0aaf0af5967fbbb2ee2e to your computer and use it in GitHub Desktop.
Save ysolis/3ff6a2b89b7e0aaf0af5967fbbb2ee2e to your computer and use it in GitHub Desktop.
---
- name: create lxc server
command: lxc init ubuntu:trusty server
ignore_errors: yes
- name: start instance if already created
shell: lxc start server && sleep 10
ignore_errors: yes
- name: copy key to new lxc instance
command: lxc file push --uid=1000 --gid=1000 --mode=0644 pubkey server/home/ubuntu/.ssh/authorized_keys
- name: get server ip
shell: lxc info server | grep eth0 | head -n 1 | cut -f 3
register: ip
- name: add to servers group
add_host:
hostname: '{{ ip.stdout }}'
groups: servers
ansible_ssh_user: ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment