#StackBounty: #bash #kickstart #anaconda #variables Kickstart CentOS 7 with pre-defined static IP and hostname (%pre) and used in KS, p…

Bounty: 50

I don’t know if this is possible, but going to ask anyways.

I am trying to Kickstart newer servers of us with CentOS 7. So far I got most working, however for some reason if I use variables in the %pre section of my Kickstart script, then it does not get parsed over to the configuration at all. Therefor I am starting to think this is not even possible?

This is what I have in the %pre section of my Kickstart:

%pre --log /tmp/pre-install.log

hostname=serverA120
ip=100.110.120.130
IFS=. read ip1 ip2 ip3 ip4 <<< "$ip"

Than during the Kickstart it should use the above filled-in information:

network  --bootproto=static --device=eth0 --gateway=100.110.$ip3.1 --ip=$ip --nameserver=1.1.1.1 --netmask=255.255.255.0
network  --hostname=$hostname.example.com

And in the %post section I also try to use the variables from %pre:

sed -i'' -e '/HOSTNAME=/d' /etc/sysconfig/network
echo HOSTNAME=$hostname.example.com >> /etc/sysconfig/network
echo GATEWAY=100.110.$ip3.1 >> /etc/sysconfig/network

echo BOOTPROTO=static >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPADDR=$ip >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo NETMASK=255.255.255.0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo BROADCAST=100.110.$ip3.255 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo NETWORK=100.110.$ip3.0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo GATEWAY=100.110.$ip3.1  >> /etc/sysconfig/network-scripts/ifcfg-eth0

echo $hostname.example.com >> /etc/hostname
sudo hostnamectl set-hostname $hostname.example.com

I checked the ifcfg-eth0 physically after I couldn’t reach the server anymore and it showed the following:

IPADDR=
BROADCAST=100.110..255
NETWORK=100.110..0
GATEWAY=100.110..1

I also checked /etc/hostname:

$hostname.example.com

So variables are not being parsed into the Kickstart. Am I doing something wrong or is it simply not possible? And is there an alternative solution perhaps for this?

Ofcourse I can manually adjust all lines manually before and after, but I wanted to make this as easy as possible without editing everything manually. In other words, I just want to fill in 2 lines and that rest gets configured as I want. This would make things easier with Kickstarting multiple servers on the long run.

I have no clue what I am doing wrong, but checking ifcfg-eth0 and hostname, it clearly shows the pre-entered variables are not being used? But like I said above, maybe it’s simply not possible, that or I am using it incorrectly.

And no I don’t want to use DHCP or similar. Because I still have to change it manually afterwards. I just want to fill in the first two lines in %pre (hostname and ip) and that it gets used automatically during the complete installation (and in %post).


Get this bounty!!!

#StackBounty: #partition #kickstart #anaconda Kickstart CentOS 7 with software RAID 1, but no LVM needed

Bounty: 50

I am going to Kickstart a CentOS 7.x installation with software RAID 1 remotely for the first time. So I am kinda inexperienced at this and wondering what I need to make this work correctly.

A CentOS 7.x kickstart with hardware raid, I use the following partition configuration:

# Disk partitioning information
part biosboot --fstype=biosboot --size=1
part /boot --fstype=ext4 --size=1024
part / --fstype=ext4 --size=10000
part /vz --fstype=ext4vz --size=40768 --grow
part swap --size=4096

This works very well.

However since I have never ever done a software RAID 1 on CentOS in general, I am wondering what the correct commands are to do so? I did some searching, but most tutorials / information I found on Google is pretty dated or uses LVM (Volume Group), which I don’t want.

I want the exact same thing as I have above, but this time with software RAID 1.

Can someone give me a workable example of how this can be done? And do I need to make changes as well to other aspects of my Kickstart configuration? E.g. bootloader configuration.

Oh and I don’t use EFI. Don’t know if that is important to mention.

Sorry for popping the question. I did search, but couldn’t find any workable information and/or examples to experiement with. And as I said; I am doing this remotely and I don’t have direct access (well unless I drive).

Thanks in advance!

//edit #1

I wanted to give it a go on a local test machine with 2x 120GB SSD’s in software RAID 1. So I went through the CentOS 7.x installer by using this tutorial for the CentOS 7.x installation GUI.

Well after a wait, I rebooted and apparently it was setup correctly:

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/md127     ext4      9.5G  4.7G  4.4G  52% /
devtmpfs       devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs          tmpfs     1.9G  9.7M  1.9G   1% /run
tmpfs          tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/md124     ext4       74G   53M   70G   1% /vz
/dev/md125     ext4      488M  149M  305M  33% /boot
tmpfs          tmpfs     379M  4.0K  379M   1% /run/user/42
tmpfs          tmpfs     379M   48K  379M   1% /run/user/1000
tmpfs          tmpfs     379M     0  379M   0% /run/user/0

So since this was setup correctly I decided to take a peak at the anaconda-ks.cfg file. No partition scheme in there. Okay, so I checked the next file “initial-setup-ks.cfg”. Same thing, no partition scheme. Sigh.

I always thought that your current setup, through the installer GUI, was reflected in those files? Wishful thinking apparently. So I am back to scratch again…

//edit #2

Nobody has an idea on how to do this correctly? 🙁


Get this bounty!!!

#StackBounty: #python #installation #anaconda #virtualenv Moving Anaconda installation from one user account to another

Bounty: 100

I apologize if this is not the correct site for this. If it is not, please let me know.

Here’s some background on what I am attempting. We are working on a series of chat bots that will go into production. Each of them will run on a environment in Anaconda. However, our setup uses tensorflow, which uses gcc to be compiled, and compliance has banned compilers from production. In addition, compliance rules also frown on us using pip or conda install in production.

As a way to get around this, I’m trying to tar the Anaconda 3 folder and move it into prod, with all dependencies already compiled and installed. However, the accounts between environments have different names, so this requires me to go into the bin folder (at the very least; I’m sure I will need to change them in the lib and pckg folders as well) and use sed -i to rename the hard coded paths to point from home<dev account>anaconda to home<prod account>anaconda, and while this seems to work, its also a good way to mangle my installation.

My questions are as follows:

  1. Is there any good way to transfer anaconda from one user to another, without having to use sed -i on these paths? I’ve already read that Anaconda itself does not support this, but I would like your input.
  2. Is there any way for me to install anaconda in dev so the scripts in it are either hard coded to use the production account name in their paths, or to use ~.
  3. If I must continue to use sed, is there anything critical I should be aware of? For example, when I use grep <dev account> *, I will some files listed as binary file matches. DO I need to do anything special to change these?

And once again, I am well aware that I should just create a new Anaconda installation on the production machine, but that is simply not an option.

Edit:
So far, I’ve changed the conda.sh and conda.csh files in /etc, as well as the conda, activate, and deactivate files in the root bin. As such, I’m able to activate and deactivate my environment on the new user account. Also, I’ve changed the files in the bin folder under the bot environment. Right now, I’m trying to train the bot to test if this works, but it keeps failing and stating that a custom action does not exist in the the list. I don’t think that is related to this, though.

Edit2:
I’ve confirmed that the error I was getting was not related to this. In order to get the bot to work properly with a ported version of Anaconda, all I had to change was the the conda.sh and conda.csh files in /etc so their paths to python use ~, do the same for the activate and deactivate files in /bin, and change the shebang line in the conda file in /bin to use the actual account name. This leaves every other file in /bin and lib still using the old account name in their shebang lines and other variable that use the path, and yet the bots work as expected. By all rights, I don’t think this should work, but it does.


Get this bounty!!!

#StackBounty: #python #anaconda #virtualenv Conda list shows a package but cannot import it

Bounty: 200

Here an issue i’m having on a conda Virtual env. I’m using ubuntu 64b guest on windows 7 host with Virtual Box.

So when i’m doing :

source activate MyVirtEnv
conda list |grep visdom
visdom                    0.1.05                        0    conda-forge

Seems to be installed right ?
Next step :

python
Python 3.5.3 |Anaconda custom (64-bit)| (default, Mar  6 2017, 11:58:13) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import visdom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'visdom'
>>> 

Ok, here i’m lost. Why does python does not recognize this package (and it’s not the only one). I’m still in my env activated when executing python.

I’m quite new to python so perhaps i’m missing a huge mistake, please be kind 😀

Thanks for your help on this one !

Update 1 :

deeplearning@deep-learning-virtual-machine:~$ source activate universe
(universe) deeplearning@deep-learning-virtual-machine:~$ python
Python 3.5.3 |Anaconda custom (64-bit)| (default, Mar  6 2017, 11:58:13) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/deeplearning/anaconda3/envs/universe/lib/python35.zip', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/plat-linux', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/lib-dynload', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages/Sphinx-1.5.6-py3.5.egg', '/home/deeplearning/gym', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages/torchvision-0.1.9-py3.5.egg']
>>> sys.executable
'/home/deeplearning/anaconda3/envs/universe/bin/python'
>>> 


Get this bounty!!!