Startup/ Init Script / Bootstrap provisioning on lxc

JakeC

Active Member
May 15, 2017
8
0
41
46
Hi All,
I feel like I'm missing something blatantly obvious, but I can't seem to find it.
I would like to automate the process of creating a Centos LXC, boostrapping it, then running the provisioning.

The hang up is the Centos 7 LXC doesn't have openssh-server installed by default.
Which I believe should be fine.

So, is there a startup script that I can write that gets run when the container is started?

I wasn't able to find that, so I looked into pct exec.
While I can run:
pct exec 106 'hostname'

I cannot seem to run:
pct exec 106 'yum install -y openssh-server'

When I try I get the following error:
root@pve:/etc/pve/nodes/pve/lxc# pct exec 106 "yum install -y openssh-server"
lxc-attach: attach.c: lxc_attach_run_command: 1290 No such file or directory - failed to exec 'yum install -y openssh-server'

I AM able to run (without the quotes):
pct exec 106 yum install openssh-server

But I can't add the -y switch without the tool complaining:
root@pve:/etc/pve/nodes/pve/lxc# pct exec 106 yum install -y openssh-server
Unknown option: y
400 unable to parse option
pct exec <vmid> [<extra-args>]


Am I just barking up the wrong tree here? Is there a simpler way of prepping a container for provisioning by ansible,chef,puppet, etc..?

Basically I figure if I can get ssh listening on the lxc then I can do whatever I want for provisioning, but I need to figure out how to script the installation of openssh-server on the new container.

Also is there a better way to view the pct documentation other than the man pages? I would even take an online version of the man pages so I could scan through and search through it.

Thank you!
 
Hi Dietmar,

that worked great! Thanks so much.

Is the "--" documented some place? I feel like I'm missing some basic documentation somewhere.

Thanks again!
 
> man pct