79 lines
2.4 KiB
YAML
79 lines
2.4 KiB
YAML
---
|
|
- hosts: localhost
|
|
# run this task in the host
|
|
connection: local
|
|
tasks:
|
|
- name: create containers cent
|
|
# get all host names from inventory
|
|
loop: "{{ groups['centos'] }}"
|
|
# use lxd_container module from ansible to create containers
|
|
lxd_container:
|
|
# container name is the hostname
|
|
name: "{{ item }}"
|
|
state: started
|
|
source:
|
|
type: image
|
|
mode: pull
|
|
server: https://images.linuxcontainers.org
|
|
protocol: simplestreams
|
|
alias: centos/8-Stream/cloud
|
|
config:
|
|
# nomad clients need some privileges to be able to run docker containers
|
|
security.nesting: "{{ 'true' if item in groups['lxdnested'] else 'false' }}"
|
|
devices:
|
|
# configure network interface
|
|
eth0:
|
|
type: nic
|
|
nictype: bridged
|
|
parent: lxdbr0
|
|
# get ip address from inventory
|
|
ipv4.address: "{{ hostvars[item].ip_address }}"
|
|
# # uncomment if you installed lxd using snap
|
|
# url: unix:/var/snap/lxd/common/lxd/unix.socket
|
|
|
|
- name: create containers ubuntu
|
|
# get all host names from inventory
|
|
loop: "{{ groups['ubuntu'] }}"
|
|
# use lxd_container module from ansible to create containers
|
|
lxd_container:
|
|
# container name is the hostname
|
|
name: "{{ item }}"
|
|
state: started
|
|
source:
|
|
type: image
|
|
mode: pull
|
|
server: https://images.linuxcontainers.org
|
|
protocol: simplestreams
|
|
alias: ubuntu/bionic/amd64
|
|
config:
|
|
# nomad clients need some privileges to be able to run docker containers
|
|
security.nesting: "{{ 'true' if item in groups['lxdnested'] else 'false' }}"
|
|
devices:
|
|
# configure network interface
|
|
eth0:
|
|
type: nic
|
|
nictype: bridged
|
|
parent: lxdbr0
|
|
# get ip address from inventory
|
|
ipv4.address: "{{ hostvars[item].ip_address }}"
|
|
# # uncomment if you installed lxd using snap
|
|
# url: unix:/var/snap/lxd/common/lxd/unix.socket
|
|
|
|
#- hosts: all
|
|
# gather_facts: no
|
|
# tasks:
|
|
# - name: Install python
|
|
# raw: test -e /usr/bin/python || (apt -y update && apt install -y python)
|
|
|
|
- hosts: db
|
|
roles:
|
|
- db
|
|
|
|
- hosts: php
|
|
roles:
|
|
- php
|
|
|
|
- hosts: ingress
|
|
roles:
|
|
- ingress
|