boot script

70 views
Skip to first unread message

aditya patnaik

unread,
Feb 9, 2015, 6:27:34 AM2/9/15
to ansible...@googlegroups.com
Hi Folks,

I am new to Ansible .I need help to create a boot script something like kickstart file using  Ansible

I already have a kickstart file (shown below)  to install centos  & KVM on a physicall host. The script will run on network (PXE)  i want in yaml format But dont know how do i go ahead :-(

when i use http://www.yamllint.com/ to test --it does not show any result. :-(

Please help!




#######################
# Kickstart
#########################
#platform=x86, AMD64, or Intel EM64T
# Install OS instead of upgrade
install
#installation path

text
lang en_US
keyboard us
timezone --utc 
 
#########################
#Networking
#########################
#network --bootproto=none
#configure by device > --device eth6
network --bootproto=static --ip=194.85.89.786 --gateway=194.85.89.781 --netmask=255.255.255.0 --nameserver=8.8.8.8 --onboot=on --hostname=mykvmhost.local
#########################
#Auth
#########################
#auth --useshadow --enablemd5
authconfig --enableshadow --passalgo=sha512
#to encrypt a password > openssl passwd -1 "RootPasswordToEncrypt"
rootpw --iscrypted $1$iIpnZZP8$QmZBJHl6z4BH6RkJF7nWz0
#rootpw plaintextpassword
#selinux --disabled
firewall --enabled --port=22:rcp
#########################
#Disks
#########################
bootloader --location=mbr
#clear everything first
zerombr
clearpart --all
#manual
part / --fstype swap --size=1 --grow
part swap --size=2048
#swap (--hibernation --recommended)
# do lvm
#part /boot --fstype=ext4 --size=500
#part pv.00 --grow --asprimary --size=1
#part volgroup vg_root pv.01
#logvol / --vgname=vg_root --size=1 --grow --name=lv_root
reboot
#########################
#After Base install
#########################
#install packages from this repo.
repo --name=CentOS6-Base --baseurl=http://centos.mirror.iweb.ca/6/os/x86_64/
repo --name=CentOS6-Updates --baseurl=http://centos.mirror.iweb.ca/6/os/x86_64/
 
#globbing eg vim* works for installing packages
%packages --ignoremissing
@core
@base
@system-admin-tools
openssh-server
kvm
virt-manager
libvirt
libvirt-python
python-virtinst
virt-top
libguestfs-tools
cloudstack-agent
openvswitch*
wget
%end
 
services --enabled=network,iptables,sshd
 
cat << EOF > /etc/sysconfig/iptables
*nat
:PREROUTING ACCEPT [819:76897]
:POSTROUTING ACCEPT [78:4939]
:OUTPUT ACCEPT [78:4939]
-A POSTROUTING -s 192.168.77.77/24 ! -d 192.168.122.54/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.77.77/24 ! -d 192.168.122.54/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.77.77/24 ! -d 192.168.122.54/24 -j MASQUERADE
COMMIT
*mangle
:PREROUTING ACCEPT [223535:201016265]
:INPUT ACCEPT [223268:200979935]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [116443:5502657]
:POSTROUTING ACCEPT [116443:5502657]
-A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m tcp --dport 49152:49216 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5900:6100 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 16509 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1798 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p gre -j ACCEPT
-A INPUT -i virbr0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p udp -m udp --dport 67 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -d 192.168.122.0/24 -o virbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 192.168.122.0/24 -i virbr0 -j ACCEPT
-A FORWARD -i virbr0 -o virbr0 -j ACCEPT
-A FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF
 
 
cat << EOF > /etc/hosts
127.0.0.1   git.example.local localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         git.example.local localhost localhost.localdomain localhost6 localhost6.localdomain6
194.85.89.786 mykvmhost.local
EOF
 
%end

Branko Majic

unread,
Feb 9, 2015, 7:03:38 AM2/9/15
to ansible...@googlegroups.com
On Mon, 9 Feb 2015 03:27:34 -0800 (PST)
aditya patnaik <adity...@gmail.com> wrote:

> Hi Folks,
>
> I am new to Ansible .I need help to create a boot script something like
> kickstart file using Ansible
>
> I already have a kickstart file (shown below) to install centos & KVM on
> a physicall host. The script will run on network (PXE) i want in yaml
> format But dont know how do i go ahead :-(
>
> when i use http://www.yamllint.com/ to test --it does not show any result.
> :-(
>
> Please help!
>

Do you want to generate the Anaconda kickstart files using Ansible for
multiple servers, or something else?

If you wish to generate Anaconda kickstart files using Ansible, you
can easily do so using the template module (see
http://docs.ansible.com/template_module.html). Just figure out what
options you need to parametrise in the kickstart file, and pass those
in to your playbook.

You should go through the Ansible tutorials first, of course.

If you're trying to do something different, some more information about
what you are trying to achieve, how you have tried to do it, and what
issues you are having would be useful in order for people to be able to
help you.

Best regards

--
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.
signature.asc

aditya patnaik

unread,
Feb 9, 2015, 7:18:58 AM2/9/15
to ansible...@googlegroups.com, bra...@majic.rs
Hello Branko

thank you for your reply.


I am not exactly looking at an Anaconda file.. I am  looking into a simple YAML script(playbook) which works as PXE boot script.
That  means I have a boot server which has Ansible installed in it. I want to place the script in that boot server  & remotely kickstart (build, configure ) a new centos host with KVM on physical server.
I want to put all the installation steps mentioned below in that playbook but confused  about the roles ,variables etc...
Reply all
Reply to author
Forward
0 new messages