Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxc default provider does not populate dnsmasq.leases #23

Closed
JeanMertz opened this issue Apr 10, 2013 · 1 comment
Closed

lxc default provider does not populate dnsmasq.leases #23

JeanMertz opened this issue Apr 10, 2013 · 1 comment

Comments

@JeanMertz
Copy link

I have this in one of my cookbooks:

lxc 'worker' do
  template 'ubuntu'
end

I can see the container being created using the ubuntu template. Chef finishes, but when looking at the server, I noticed that it's actually pretty hard to find out the internal IP of the new container.

This is what I see after connecting:

$ lxc-list
STOPPED
  worker

$ lxc-start -n worker -d

$ lxc-list
RUNNING
  worker

$ cat /var/lib/misc/dnsmasq.leases
# empty

$ lxc-console -n worker
# I can correctly log in

$ cat /etc/dnsmasq.d/lxc
# Tell any system-wide dnsmasq instance to make sure to bind to interfaces
# instead of listening on 0.0.0.0
# WARNING: changes to this file will get lost if lxc is removed.
bind-interfaces
except-interface=lxcbr0

$ cat /etc/default/lxc
LXC_AUTO=true
USE_LXC_BRIDGE=true
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"
LXC_SHUTDOWN_TIMEOUT=120
MIRROR="http://archive.ubuntu.com/ubuntu"

$ ssh ubuntu@10.0.3.1
Permission denied (publickey).
# I can connect (but denied due to ssh restrictions)

$ ssh ubuntu@10.0.3.2
ssh: connect to host 10.0.3.2 port 22: No route to host
# I'm not sure about this last one. The DHCP range starts at *.2,
# but the NETWORK range also includes *.1, but this could possibly be the DCHP router or something.

The problem with this is that I need to find out how to get the IP of the container, so I can pass it along to our Jenkins CI server to work with. Any thoughts?

Here's my run_list:

run_list *%w[
  role[base]                # build-essentials, git, etc…
  recipe[jenkins::node_ssh] # jenkins-slave
  recipe[lxc]               # this cookbook, default action
  recipe[jenkins-slave]     # lxc 'worker' with template 'ubuntu'
]

And this is the only (relevant) overridden attribute:

override_attributes(lxc: { allowed_types: %w[ubuntu] })

NOTE: I am using the new-develop branch

@chrisroberts
Copy link
Contributor

Quick way to grab IP address:

sudo ruby -r'elecksee/lxc' -e 'puts Lxc.new("CONTAINER_NAME").container_ip'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants