I have a setup of ansible and different server for LXD. Can anyone provide me the plugin that can be used to do stuffs inside LXD container through ansible like installing nginx or removing default ubuntu user.
Lxd version: 4 (ubuntu 20.04 LTS)
Ansible version: 5(ansible-core 2.12) --> ubuntu 20.04 LTS
My tasks>main.yml looks like this.
- name: dynamic-site-host
add_host:
name: "{{ item.container_name }}-host"
ansible_host: "{{ ansible_host }}"
#ansible_connection: lxd
ansible_ssh_extra_args: "{{ item.container_name }}"
ansible_ssh_user: root
ansible_python_interpreter: /usr/bin/python3
with_items: "{{ container_params }}"
- name: set-dynamic-site-host-name
delegate_to: "{{ item.container_name }}-host"
set_fact:
site_host_name: "{{ item.container_name }}-host"
with_items: "{{ container_params }}"
- name: set-site-vars-dynamically
delegate_to: "{{ site_host_name }}"
set_fact:
site_params: "{{ item }}"
with_items: "{{ container_params }}"
- name: Remove the user 'ubuntu'
delegate_to: "{{ site_host_name }}"
user:
name: ubuntu
state: absent
remove: yes
ansible.cfg
[defaults]
inventory= ./hosts
#connection_plugins = ./plugins/lxc_ssh/
ansible_host_key_checking= false
host file
[default]
hosting ansible_host=138.xxx.xxx.xx ansible_ssh_user=root