Creating an Elastix image for the cloud

DOWNLOAD THE IMAGE AND INSTALL IT

We used the one for 3.0.0, but you can use whatever you want from elastix web. Normally you will want to install it to a single ext3/ext4 partition so we can resize it when deploying to an instance.

Fundamental steps are:

  • Select partition method. 1 partition ext4/ext3. No LVM. LVM is by default so you must override.
  • Set root password: ‘elastix’
  • Set mysql password. Something simple, leave blank. (Set it after).

 

FOLLOW CLOUD IMAGE CONVENTIONS

You should do all steps in this manual page from “Install the ACPI service”. For this to happen you must login in the machine with root:elastix user that we set on installation.

It’s very important that acpi is installed and also the cloud-init. The former will let your system be rebooted/shutdown by openstack, and the latter will allow the system to integrate into openstack by injecting ssh keys and metadata.

I also edited /etc/cloud/cloud.cfg to set gecos info of the default user to Elastix Cloud User. Just for info.

Another thing I like to do is to inform about what the user should do. I create a file with name /etc/motd.local

Please you must update the following settings:

 Set the root password or remove the ability to login. Currently 'elastix'.
 Set mysql root password. Currently blank. 
 Set admin panel 'superadmin' pass.


And modify /usr/local/sbin/motd.sh:

Add this to the end.

 

cat /etc/motd.local
echo ""

Edit

users:
 - default

disable_root: 1
ssh_pwauth: 0

cc_ready_cmd: ['/bin/true']
locale_configfile: /etc/sysconfig/i18n
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
ssh_deletekeys: 0
ssh_genkeytypes: ~
ssh_svcname: sshd
syslog_fix_perms: ~

cloud_init_modules:
 - bootcmd
 - resizefs
 - set_hostname
 - rsyslog
 - ssh

cloud_config_modules:
 - mounts
 - ssh-import-id
 - locale
 - set-passwords
 - timezone
 - puppet
 - disable-ec2-metadata
 - runcmd

cloud_final_modules:
 - rightscale_userdata
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - keys-to-console
 - phone-home
 - final-message

system_info:
 default_user:
 name: centos
 lock_passwd: true
 gecos: Elastix Cloud User
 groups: [wheel, adm]
 sudo: ["ALL=(ALL) NOPASSWD:ALL"]
 shell: /bin/bash
 distro: rhel
 paths:
 cloud_dir: /var/lib/cloud
 templates_dir: /etc/cloud/templates
 ssh_svcname: sshd

# vim:syntax=yaml

 

NOTE: I didn’t deleted the VM in case I have to do any updates.

MAKING THE IMAGE TO AUTORESIZE

We need it to autoresize the partition to fit the whole disk on the VM. So we need to install an additional tool:

# yum install cloud-utils-growpart

And execute following steps:

# Set up to grow root in initramfs
cat << EOF > 05-grow-root.sh
#!/bin/sh
/bin/echo
/bin/echo Resizing root filesystem
growpart --fudge 20480 -v /dev/vda 1
e2fsck -f /dev/vda1
resize2fs /dev/vda1
EOF
chmod +x 05-grow-root.sh
dracut --force --include 05-grow-root.sh /mount --install 'echo awk grep fdisk sfdisk growpart partx e2fsck resize2fs' "$(ls /boot/initramfs-*)" $(ls /boot/|grep vmlinuz|sed s/vmlinuz-//g)
rm -f 05-grow-root.sh

 

FIX INSTALLATION

In my case I had to remove the udev rules that put the eth interface as the first one, because openstack adds a line to this file and since there’s one already I get first interface being eth1. So cloud-init is not initialized because all network stuff is configured as eth0. It means that you don’t have public key, nor network.

Bad stuff.

So remove all lines but two first from /etc/udev/rules.d/70-persistent-net.rules or just delete it.

Also you need to allow anyone in the group wheel to sudo.

This is done editing /etc/sudoers:

 

## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL

 

 

SHRINK THE IMAGE

I don’t want to have a 4GB image when it can be less than that. So I will resize.

 

Follow this tutorial for shrinking. I will try to resume steps:

# losetup /dev/loop0 /var/lib/libvirt/images/intermediate-pbx.img
# partprobe /dev/loop0
# gparted /dev/loop0
### And after a while
# truncate --size=$[(4196352+1)*512] /var/lib/libvirt/images/intermediate-pbx.img

 

Once we done it. My image partition shrinked from 4GB to 1.8GB. This is a substancial gain.

 

THE PROBLEM

After resizing I realized that grub failed to boot with “Geom error”. This means that grub still have the old information of the disk so it cannot find right places to make the system bootable.

The only way to fix it is to mounting the disk on the VM and boot from CD with rescue mode. You can enable rescue mode in the Elastix ISO by writing “linux rescue” on the grub prompt.

RecoverPrompt

 

Once is booted you will have your system ready on /mnt/sysimage [check this]

# chroot /mnt/sysimage
# source /etc/profile
# grub-install /dev/vda

And you are set. The system is recovered.

RecoverPrompt_cmd

 

 

UPLOAD IMAGE

I used horizon to do it but it should be easy to do from command line also. Don’t forget to set the following settings:

 

  • Upload from file. The img file, we just created.
  • Format: Raw
  • Architecture: x86_64
  • Minimal disk size: 2GB <- We need at least 1.8 GB.

 

It takes a little bit to upload because it’s almost 2GB.

 

Done!

6 thoughts on “Creating an Elastix image for the cloud

  1. Can you help me

    I want install an instance of elastix but i don`t can convert the .iso in other format
    how i can do this

    help me

    • Hi Adriana,

      Normally you shouldn’t convert it. You can just install from iso. You can mount iso directly on linux, and also emulate a CD/DVD-READER. Once installed the system is in standard format type like raw, qcow2, etc and you can convert between disk formats.

      Why do you need to convert it?

      Best regards

      • Because I don’t can lauch the instances. I convert to format qcow and i have an error of ovs-switch. Help me I need lauch elastix in openstack but I can’t understand the steps in this tutorial. I speak spanish and i don´t write good

        • Hi Adriana,
          Can you post a little more info. I’m not an expert on Elastix. But I can tell you that ovs-switch is part of openstack but not really related to qcow format or any other. Have you an openstack installation working? I think you must be sure of that before trying anything else. About the qcow format. You can upload if you want a raw image. I mean. The fastest path is to install the elastix in a VM in local and once is installed you can upload to the cloud. The only care you have to have is configure it by dhcp.

          If you post some info I can help a little bit. But try the path I tell you by installing local VM first.

          • I’m installing on the local machine from .iso but really gives us an error that can not access the host. Only allows to launch instances that are art like ubuntu but not the elastix.iso that is our problem and we want to achieve start a elastix to finish the project soon but found it is impossible to launch the isntancia from the .iso. We could help with any suggestions?

          • Hi Adriana,
            Sorry for the delay. I was really busy.
            Ok. You should have no problems to launch the instance with an ISO in local machine. This has nothing to do with Openstack. If you cannot do it. Then you have to check if you have proper virtualization support, check http://www.linux-kvm.org/page/Processor_support. That you have installed all software https://help.ubuntu.com/community/KVM/Installation, in case of ubuntu. In my case, Sony blocked the VM extensions of the processor in bios in my laptop so I cannot use my laptop for this. They are so cute…

            I cannot help you there much. It seems to be a local problem of your installation because ISO is supported by default.
            Hope it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*
Website