Last active
November 7, 2017 19:30
-
-
Save hipertracker/240cf208000190b96ee13874e47ca964 to your computer and use it in GitHub Desktop.
Ansible - create LXD containers
This file contains hidden or 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: localhost | |
connection: local | |
tasks: | |
- name: Create started inventory containers | |
lxd_container: | |
name: "{{ item }}" | |
state: started | |
source: | |
type: image | |
mode: pull | |
server: https://images.linuxcontainers.org | |
protocol: lxd | |
alias: ubuntu/xenial/amd64 | |
profiles: ['default'] | |
wait_for_ipv4_addresses: true | |
timeout: 6000 | |
with_inventory_hostnames: | |
- all | |
- name: Add Python 2 | |
delegate_to: "{{ item }}" | |
raw: test -e /usr/bin/python || (apt update && apt install -y python) | |
with_inventory_hostnames: | |
- all | |
- name: Add authorized keys | |
delegate_to: "{{ item }}" | |
authorized_key: | |
user: root | |
state: present | |
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" | |
with_inventory_hostnames: | |
- all | |
This file contains hidden or 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
[containers] | |
web1 ansible_connection=lxd | |
db1 ansible_connection=lxd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment