# Proxmox

**URL:** <https://forum.ansible.com/t/proxmox/34328>\
**Category:** Ansible Project\
**Created:** [December 13, 2020, 10:32pm UTC](https://forum.ansible.com/t/proxmox/34328 "2020-12-13T22:32:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pim\_Janssen](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Pim\_Janssen](https://forum.ansible.com/u/Pim_Janssen)\
**Post date:** [December 13, 2020, 10:32pm UTC](https://forum.ansible.com/t/proxmox/34328/1 "2020-12-13T22:32:11Z")

</div>

Hi everyone,

As i am new to Ansible i still have a lot to learn.

I have been playing with Ansible and Proxmox for some time. I want to run Ansible within a Proxmox container without having to install SSH inside every container.  
It’s possible to run commands inside a container using SSH on the Proxmox host. So far so good. I am able to run Ansible inside a container by modifying (prefixing) the ansible\_python\_interpreter variable.

Currently i need to hard code the container id inside the ansible\_python\_interpreter variable. Also i have to make sure the path on the host and the mounted shared folder have the same path. Else Ansible will try to run the wrong python file.

I would like to make this in a way i can specify the container id and the Proxmox host and have Ansible run commands inside the container.

Anyone any suggestions where to start? Should i make a new connection plugin? Or is there any other way to get the same result?

Regards,

Pim

---

<div class="post-metadata">

**Author:** ![Martin\_Etcheverry](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Martin\_Etcheverry](https://forum.ansible.com/u/Martin_Etcheverry)\
**Post date:** [December 14, 2020, 1:15pm UTC](https://forum.ansible.com/t/proxmox/34328/2 "2020-12-14T13:15:10Z")

</div>

Hi Pim , maybe this can work for you; you can run a command inside the container with something like that:

- name: run command  
hosts: proxmox  
tasks:
- name: Run command in container  
lxc\_container:  
name: 133  
state: started  
container\_command: service ssh restart

---

<div class="post-metadata">

**Author:** ![Pim\_Janssen](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Pim\_Janssen](https://forum.ansible.com/u/Pim_Janssen)\
**Post date:** [December 14, 2020, 7:19pm UTC](https://forum.ansible.com/t/proxmox/34328/3 "2020-12-14T19:19:01Z")

</div>

Thanks for the reply. This could run a command inside a container. But i would like to run a complete playbook inside a container.

Now i can set something like: ansible\_connection=ssh ansible\_python\_interpreter=“pct exec 212 – python3” ansible\_remote\_tmp=/var/lib/lxc/212/rootfs/var/tmp/ (it requires python3 inside the container)

This kindda works. But it requires the container ID on 2 places inside the host connection settings. It also requires me to make a symlink inside the container so that the /var/lib/lxc/212/rootfs/var/tmp/ folder points to the correct tmp folder where the files where placed. I don’t mind the symlink. But i don’t like it to put it as a extra task in the playbook. I would like ansible to handle it for me.

Thanks,

Pim
