forked from ungleich-public/cdist
		
	Merge pull request #457 from panter/fixes/preos
Fixes for cdist preos command
This commit is contained in:
		
				commit
				
					
						f7ab5d4869
					
				
			
		
					 2 changed files with 21 additions and 7 deletions
				
			
		| 
						 | 
					@ -18,7 +18,12 @@
 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Check whether system has hostnamectl
 | 
					# Check whether system has hostnamectl and it's usable, i.e. don't
 | 
				
			||||||
 | 
					# try to use it when systemd isn't running yet.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
command -v hostnamectl || true
 | 
					if command -v hostnamectl >/dev/null && hostnamectl status >/dev/null 2>&1; then
 | 
				
			||||||
 | 
					  echo "yes"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  true
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,8 +38,9 @@ DEFAULT_MANIFEST = """
 | 
				
			||||||
for pkg in \
 | 
					for pkg in \
 | 
				
			||||||
    file \
 | 
					    file \
 | 
				
			||||||
    linux-image-amd64 \
 | 
					    linux-image-amd64 \
 | 
				
			||||||
 | 
					    lsb-release \
 | 
				
			||||||
    openssh-server curl \
 | 
					    openssh-server curl \
 | 
				
			||||||
    syslinux grub2 \
 | 
					    pxelinux syslinux-common grub2 \
 | 
				
			||||||
    gdisk util-linux lvm2 mdadm \
 | 
					    gdisk util-linux lvm2 mdadm \
 | 
				
			||||||
    btrfs-tools e2fsprogs jfsutils reiser4progs xfsprogs; do
 | 
					    btrfs-tools e2fsprogs jfsutils reiser4progs xfsprogs; do
 | 
				
			||||||
    __package $pkg --state present
 | 
					    __package $pkg --state present
 | 
				
			||||||
| 
						 | 
					@ -63,7 +64,7 @@ eof
 | 
				
			||||||
# fix the bloody 'stdin: is not a tty' problem
 | 
					# fix the bloody 'stdin: is not a tty' problem
 | 
				
			||||||
__line /root/.profile --line 'mesg n' --state absent
 | 
					__line /root/.profile --line 'mesg n' --state absent
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__hostname preos
 | 
					__hostname --name preos
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PreOSExistsError(cdist.Error):
 | 
					class PreOSExistsError(cdist.Error):
 | 
				
			||||||
| 
						 | 
					@ -85,11 +86,11 @@ class PreOS(object):
 | 
				
			||||||
        self.arch = arch
 | 
					        self.arch = arch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.command = "debootstrap"
 | 
					        self.command = "debootstrap"
 | 
				
			||||||
        self.suite  = "wheezy"
 | 
					        self.suite  = "stable"
 | 
				
			||||||
        self.options = [ "--include=openssh-server",
 | 
					        self.options = [ "--include=openssh-server",
 | 
				
			||||||
            "--arch=%s" % self.arch ]
 | 
					            "--arch=%s" % self.arch ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.pxelinux = "/usr/lib/syslinux/pxelinux.0"
 | 
					        self.pxelinux = "/usr/lib/PXELINUX/pxelinux.0"
 | 
				
			||||||
        self.pxelinux_cfg = """
 | 
					        self.pxelinux_cfg = """
 | 
				
			||||||
DEFAULT preos
 | 
					DEFAULT preos
 | 
				
			||||||
LABEL preos
 | 
					LABEL preos
 | 
				
			||||||
| 
						 | 
					@ -177,11 +178,18 @@ cp -L "$src" "$real_dst"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def create_pxelinux(self):
 | 
					    def create_pxelinux(self):
 | 
				
			||||||
        dst = os.path.join(self.out_dir, "pxelinux.0")
 | 
					        dst = os.path.join(self.out_dir, "pxelinux.0")
 | 
				
			||||||
        src = "%s/usr/lib/syslinux/pxelinux.0" % self.target_dir
 | 
					        src = "%s/usr/lib/PXELINUX/pxelinux.0" % self.target_dir
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        log.info("Creating pxelinux.0  ...")
 | 
					        log.info("Creating pxelinux.0  ...")
 | 
				
			||||||
        shutil.copyfile(src, dst, follow_symlinks=True)
 | 
					        shutil.copyfile(src, dst, follow_symlinks=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def create_ldlinux(self):
 | 
				
			||||||
 | 
					        dst = os.path.join(self.out_dir, "ldlinux.c32")
 | 
				
			||||||
 | 
					        src = "%s/usr/lib/syslinux/modules/bios/ldlinux.c32" % self.target_dir
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        log.info("Creating ldlinux.c32  ...")
 | 
				
			||||||
 | 
					        shutil.copyfile(src, dst, follow_symlinks=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def create_pxeconfig(self):
 | 
					    def create_pxeconfig(self):
 | 
				
			||||||
        configdir = os.path.join(self.out_dir, "pxelinux.cfg")
 | 
					        configdir = os.path.join(self.out_dir, "pxelinux.cfg")
 | 
				
			||||||
        configfile = os.path.join(configdir, "default")
 | 
					        configfile = os.path.join(configdir, "default")
 | 
				
			||||||
| 
						 | 
					@ -218,6 +226,7 @@ cp -L "$src" "$real_dst"
 | 
				
			||||||
        self.create_initramfs()
 | 
					        self.create_initramfs()
 | 
				
			||||||
        self.create_pxeconfig()
 | 
					        self.create_pxeconfig()
 | 
				
			||||||
        self.create_pxelinux()
 | 
					        self.create_pxelinux()
 | 
				
			||||||
 | 
					        self.create_ldlinux()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup_initial_manifest(self, user_initial_manifest, replace_manifest):
 | 
					    def setup_initial_manifest(self, user_initial_manifest, replace_manifest):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue