хочу с помощью одной playbook поднимать контейнер и сразу же нагружать его задачами. Но в документации очень все расплывчато и не особо работает.
Вот пример моей тестовой плейбуки:
- hosts: localhost
connection: local
tasks:
- name: Create a profile
lxd_profile:
name: test
config: {}
description: test
devices:
eth0:
ipv4.address: 10.9.9.10
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
- name: Create a started container
lxd_container:
name: mycontainer
state: started
source:
type: image
mode: pull
server: https://images.linuxcontainers.org
protocol: simplestreams
alias: ubuntu/xenial/amd64
profiles: ["test"]
wait_for_ipv4_addresses: true
timeout: 600
- name: register container
add_host:
name: mycontainer
ansible_host: localhost:mycontainer
ansible_connection: lxd
- hosts:
- mycontainer
tasks:
- name: Install packages
action: apt pkg={{ item }} state=present
with_items:
- nginx
она создает профиль и контейнер с этим профилем, но тестовый таск «Install packages» оно не может.
fatal: [mycontainer]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp/ansible-tmp-1575368853.0-168098739882633 `\" && echo ansible-tmp-1575368853.0-168098739882633=\"` echo ~/.ansible/tmp/ansible-tmp-1575368853.0-168098739882633 `\" ), exited with result 1", "unreachable": true}
Я перебрал довольно много вариантов, как, блин , заставить это работать?
команды типа lxc exec не предлагать, ставить на контейнер sshd и заходить по нему тоже не предлагать - это все костыли.