Hello, I am trying to create a VM using puppet and vmbuilder. I''ve got the following declaration (now very simplified): define virtual_machine ($ip) { exec {"create_vm_${name}": command => "/usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 -- cpus=1 --rootsize=5096", unless => "/usr/bin/test -d /var/lib/kvm/${name}", } } When I run puppetd in debugging mode on the client I get this: debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ Exec[create_vm_anewvm]: Executing check ''/usr/bin/test -d /var/lib/kvm/ anewvm'' debug: Executing ''/usr/bin/test -d /var/lib/kvm/anewvm'' debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ Exec[create_vm_anewvm]: Changing returns debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ Exec[create_vm_anewvm]: 1 change(s) debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ Exec[create_vm_anewvm]: Executing ''/usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 --cpus=1 --rootsize=5096'' debug: Executing ''/usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 -- cpus=1 --rootsize=5096'' notice: //Node[10.0.0.165]/Virtual_machine[anewvm]/ Exec[create_vm_anewvm]/returns: executed successfully debug: Finishing transaction 70279583715580 with 1 changes But... the command is never executed. If I run /usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 --cpus=1 --rootsize=5096 by hand I get: root@venice:/etc/puppet# /usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 --cpus=1 --rootsize=5096 2010-04-25 19:30:16,738 INFO : Creating disk image: /tmp/ vmbuilderConQHr/disk0.img 2010-04-25 19:30:16,745 INFO : Adding partition table to disk image: /tmp/vmbuilderConQHr/disk0.img 2010-04-25 19:30:16,838 INFO : Adding type 1 partition to disk image: /tmp/vmbuilderConQHr/disk0.img 2010-04-25 19:30:16,896 INFO : Adding type 3 partition to disk image: /tmp/vmbuilderConQHr/disk0.img 2010-04-25 19:30:16,903 INFO : [0] ../../libparted/filesys.c:147 (ped_file_system_type_get): File system alias linux-swap(new) is deprecated 2010-04-25 19:30:16,954 INFO : Creating loop devices corresponding to the created partitions 2010-04-25 19:30:16,967 INFO : Creating file systems 2010-04-25 19:30:16,971 INFO : mke2fs 1.41.9 (22-Aug-2009) 2010-04-25 19:30:17,596 INFO : mkswap: /dev/mapper/loop1p2: warning: don''t erase bootbits sectors 2010-04-25 19:30:17,597 INFO : on whole disk. Use -f to force. 2010-04-25 19:30:17,604 INFO : Mounting target filesystems 2010-04-25 19:30:17,612 INFO : Installing guest operating system [...] And the operation takes a while. So I''m really stuck, it says it executes that command and that the command is successful, but apparently, it doesnt execute the command, or it is not successful (considering that I see no output, that the VM is not created, that the command returns in less than a second although it should take 3min+)... I tried replacing the vmbuilder command by a simple "touch /tmp/ test" , that one works. Any help would be much appreciated, I''ve been trying everything for hours :( -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Apr 25, 2010, at 11:32 AM, Yann wrote:> Hello, I am trying to create a VM using puppet and vmbuilder. I''ve got > the following declaration (now very simplified): > > define virtual_machine ($ip) { > exec {"create_vm_${name}": > command => "/usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 -- > cpus=1 --rootsize=5096", > unless => "/usr/bin/test -d /var/lib/kvm/${name}", > } > } > > When I run puppetd in debugging mode on the client I get this: > > > debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ > Exec[create_vm_anewvm]: Executing check ''/usr/bin/test -d /var/lib/kvm/ > anewvm'' > debug: Executing ''/usr/bin/test -d /var/lib/kvm/anewvm'' > debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ > Exec[create_vm_anewvm]: Changing returns > debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ > Exec[create_vm_anewvm]: 1 change(s) > debug: //Node[10.0.0.165]/Virtual_machine[anewvm]/ > Exec[create_vm_anewvm]: Executing ''/usr/bin/vmbuilder kvm ubuntu -d > CNDR -v -m 512 --cpus=1 --rootsize=5096'' > debug: Executing ''/usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m 512 -- > cpus=1 --rootsize=5096'' > notice: //Node[10.0.0.165]/Virtual_machine[anewvm]/ > Exec[create_vm_anewvm]/returns: executed successfully > debug: Finishing transaction 70279583715580 with 1 changes > > > But... the command is never executed. If I run /usr/bin/vmbuilder kvm > ubuntu -d CNDR -v -m 512 --cpus=1 --rootsize=5096 by hand I get: > > root@venice:/etc/puppet# /usr/bin/vmbuilder kvm ubuntu -d CNDR -v -m > 512 --cpus=1 --rootsize=5096 > 2010-04-25 19:30:16,738 INFO : Creating disk image: /tmp/ > vmbuilderConQHr/disk0.img > 2010-04-25 19:30:16,745 INFO : Adding partition table to disk > image: /tmp/vmbuilderConQHr/disk0.img > 2010-04-25 19:30:16,838 INFO : Adding type 1 partition to disk > image: /tmp/vmbuilderConQHr/disk0.img > 2010-04-25 19:30:16,896 INFO : Adding type 3 partition to disk > image: /tmp/vmbuilderConQHr/disk0.img > 2010-04-25 19:30:16,903 INFO : [0] ../../libparted/filesys.c:147 > (ped_file_system_type_get): File system alias linux-swap(new) is > deprecated > 2010-04-25 19:30:16,954 INFO : Creating loop devices corresponding > to the created partitions > 2010-04-25 19:30:16,967 INFO : Creating file systems > 2010-04-25 19:30:16,971 INFO : mke2fs 1.41.9 (22-Aug-2009) > 2010-04-25 19:30:17,596 INFO : mkswap: /dev/mapper/loop1p2: > warning: don''t erase bootbits sectors > 2010-04-25 19:30:17,597 INFO : on whole disk. Use -f to > force. > 2010-04-25 19:30:17,604 INFO : Mounting target filesystems > 2010-04-25 19:30:17,612 INFO : Installing guest operating system > [...] > > And the operation takes a while. > So I''m really stuck, it says it executes that command and that the > command is successful, but apparently, it doesnt execute the command, > or it is not successful (considering that I see no output, that the VM > is not created, that the command returns in less than a second > although it should take 3min+)... > > I tried replacing the vmbuilder command by a simple "touch /tmp/ > test" , that one works. > > Any help would be much appreciated, I''ve been trying everything for > hours :( >I have couple of wild guesses if you run out of ideas: 1) For some reason the program is silently failing if there isn''t an associated console. 2) It''s trying to use environmental variables that don''t exist in the session created by puppet. 3) Something is wrong with your ''unless'' statement. The easiest to check is 3. Just remove the unless statement and try again. I''d try this first since it''s trivial. I think you can mostly test 1 by trying to run the command while redirecting the input from /dev/null You can indirectly do a partial job of testing 2 putting that command in a bash shell script and then executing the script explicitly using bash with the -l flag so bash will reconstruct some of the variables. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hello Patrick, thank you very much for your help. I tested everything you said without much success. I ended up replacing my command by an "env" and reproducing the puppet''s shell environment variable in my shell to see if that could have an impact. It seems my puppet is running with an incorrect locale: LANG=C [...] LC_MESSAGES=C [...] LC_ALL=C root@venice:/tmp# /usr/bin/vmbuilder kvm ubuntu 2010-04-26 11:58:14,501 INFO : Cleaning up locale-gen does not recognize your locale ''C'' No idea why I wasnt able to catch those error messages before. I will continue to work on it and let you know if I manage to see where the locale is defined and why I wasnt seing that message (even after adding a 2>&1 > /tmp test at the end of the command line) Thanks -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2010-Apr-26 11:53 UTC
Re: [Puppet Users] Re: Problem using exec with vmbuilder
Yann <yann.hamon@gmail.com> writes:> Hello Patrick, thank you very much for your help. I tested everything you > said without much success. I ended up replacing my command by an "env" and > reproducing the puppet''s shell environment variable in my shell to see if > that could have an impact. It seems my puppet is running with an incorrect > locale: > > LANG=C > [...] > LC_MESSAGES=C > [...] > LC_ALL=C > > root@venice:/tmp# /usr/bin/vmbuilder kvm ubuntu > 2010-04-26 11:58:14,501 INFO : Cleaning up > locale-gen does not recognize your locale ''C''O_o The ''C'' locale means "the strings built in to the binary", and is the fallback when there isn''t anything else available. My guess is that the vmbuilder application has a foolish bug that uses LANG from the environment either by default, or by design, to help pre-populate the container. Try specifying the locale on the command line for vmbuilder, or overriding it in the puppet environment in the exec. Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 2010-04-26 13:08, Yann wrote:> It seems my puppet is running with an incorrect locale: > > LANG=C > [...] > LC_MESSAGES=C > [...] > LC_ALL=C > > root@venice:/tmp# /usr/bin/vmbuilder kvm ubuntu > 2010-04-26 11:58:14,501 INFO : Cleaning up > locale-gen does not recognize your locale ''C''"C" is a very much valid locale. I don''t know what locale-gen does, so I don''t know if it is locale-gen that is broken or if vmbuilder is broken calling locale-gen when it shouldn''t. I have never used vmbuilder myself, but it does sound very, very weird that it wouldn''t be able to run when you use the C locale. That''s the most basic of all locales, and is actually entirely equivalent to not using locales at all.> No idea why I wasnt able to catch those error messages before. I will > continue to work on it and let you know if I manage to see where the > locale is defined and why I wasnt seing that message (even after > adding a 2>&1 > /tmp test at the end of the command line)That redirection should be the other way around: >/tmp/test 2>&1. Redirections are executed from left to right. Your redirection means "Clone the file descriptor for the current standard output [likely /dev/null] onto the file descriptor for standard error. Then open /tmp/test as the new standard output." After that, standard error will be open to /dev/null. Switching them around turns the meaning into "Open /tmp/test as standard output. Then clone the file descriptor for the current standard output [which is now /tmp/test] onto the file descriptor for standard error." /Bellman -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2010-Apr-27 04:29 UTC
Re: [Puppet Users] Re: Problem using exec with vmbuilder
Thomas Bellman <bellman@nsc.liu.se> writes:> On 2010-04-26 13:08, Yann wrote: > >> It seems my puppet is running with an incorrect locale: >> >> LANG=C >> [...] >> LC_MESSAGES=C >> [...] >> LC_ALL=C >> >> root@venice:/tmp# /usr/bin/vmbuilder kvm ubuntu >> 2010-04-26 11:58:14,501 INFO : Cleaning up >> locale-gen does not recognize your locale ''C'' > > "C" is a very much valid locale. I don''t know what locale-gen does, so I > don''t know if it is locale-gen that is broken or if vmbuilder is broken > calling locale-gen when it shouldn''t.The later: locale-gen is the Debian (and, so, Ubuntu) process that generates the individual locale data files from the source material — because the later is much smaller (apparently) than the former.> I have never used vmbuilder myself, but it does sound very, very weird that > it wouldn''t be able to run when you use the C locale.I suspect it is trying to *generate* the ''C'' locale, which isn''t going to work nearly as well as trying to run in it. :) Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.