0

I've got a host server which runs Jenkins. I'd like Jenkins to automatically create new containers and prepare those containers with SALT. The ultimate purpose is to use these containers to test code.

What is the best way to create a new container, install salt-minion, and then provision the server with salt?

I've tried something along the lines of lxc-attach -n myContainer -- salt-call --local state.highstate but I'm running into problems doing that. If i run lxc-attach -n [name] -- [command] manually on the command line it works. However, doing this from a script gives me errors.

lxc-start -n "$1" -d
lxc-attach -n "$1" -- apt-get update

...results in...

Starting the container 'test2'...
Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://security.ubuntu.com trusty-security InRelease
Err http://security.ubuntu.com trusty-security Release.gpg
  Could not resolve 'security.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
  Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease  

... and multiple more errors. I'm running both the script and the commands manually on the command line as the same user.

What could I be doing wrong here?

2
  • Showing the error you got would be helpful.
    – gxx
    Jan 21, 2016 at 9:10
  • In general a "could not resolve" error is indicative of DNS issues, if networking is set up correctly check resolv.conf
    – HBruijn
    Jan 31, 2016 at 14:20

1 Answer 1

0

It appears that i attempted to run apt-get update too quickly after i started the container (in the background). The network as apparently not ready, and this all commands (which relied on network) failed.

I added sleep 5s to the provisioning script, and it worked fined.

lxc-start -n "$1" -d
sleet 5
lxc-attach -n "$1" -- apt-get update

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .