New LXC user and first post on the forum.
I’ve been testing LXC for a few days… and well… this is great. I’ve been searching for a tool like this and by luck on a podcast someone referred LXC.
I don’t know how a tool like LXC is not common knowledge.
My question. I’ve made some tests using Ansible using the community.general
ansible-galaxy collection install community.general -f
The problem that I’ve is that I’m able to run tasks on the containers but my knowledge of Ansible does not allow me to run tasks on the Host System on the same Ansible Playbook.
I’ve LXC installed on a VMWare VM, and I need to run this LXC commands on the Host System:
lxc config device add proxy myport80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80 proxy_protocol=true lxc config device add proxy myport443 proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443 proxy_protocol=true
The hosts.yml Ansible Script is the following:
all: vars: ansible_connection: lxd ansible_user: root ansible_become: no children: vmware: vars: ansible_lxd_remote: 172.16.148.145 # this IP is the name of the remote lxd... hosts: ubuntu22-0402:
With this hosts.yml I’m able to target the LXC container “ubuntu22-0402”.
What I need to do on the same playbook is to target the “vmware” (172.16.148.145). I don’t know if this is possible.
I know that this is an Ansible question, but I asked here because I think this is a specific question and someone who runs LXC with Ansible probably have needed to do something similar.
Maybe the only solution is to target “vmware” (172.16.148.145) in another Playbook with another “hosts.yml”.