├── Fedora ├── files │ └── images │ │ └── README.md ├── conf │ ├── screenrc │ ├── ztps-test.com.zone │ ├── named.conf │ ├── ntp.conf │ ├── rsyslog.conf │ ├── dhcpd.conf │ ├── prosody.cfg.lua │ ├── httpd.conf │ └── ejabberd.cfg ├── http │ ├── ks-32b.cfg │ └── ks-net.cfg ├── ztps-fedora_20_i386.json ├── scripts │ ├── setup.sh │ └── setup-32b.sh └── ztps-fedora_20_x86_64.json ├── Ubuntu ├── files │ └── images │ │ └── README.md ├── conf │ ├── 001-ztpserver │ ├── named.conf.local │ ├── screenrc │ ├── named.conf.default-zones │ ├── ports.conf │ ├── db.ztps-test.com │ ├── named.conf │ ├── ntp.conf │ ├── rsyslog.conf │ ├── dhcpd.conf │ ├── prosody.cfg.lua │ └── ejabberd.cfg ├── http │ └── preseed.cfg ├── scripts │ └── setup.sh └── ztps-ubuntu-12.04.4_amd64.json ├── .gitignore ├── create-ztpserver.py ├── README.md └── lib └── eosplusvnets.py /Fedora/files/images/README.md: -------------------------------------------------------------------------------- 1 | #Demo Files 2 | ##files/images 3 | Place the vEOS.swi here 4 | -------------------------------------------------------------------------------- /Ubuntu/files/images/README.md: -------------------------------------------------------------------------------- 1 | #Demo Files 2 | ##files/images 3 | Place the vEOS.swi here 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *debug.log 2 | *.iso 3 | *.rpm 4 | *.swi 5 | *.swix 6 | *.py[o|c] 7 | **/packer_cache 8 | **/*-vmware/ 9 | **/*-vbox/ 10 | -------------------------------------------------------------------------------- /Ubuntu/conf/001-ztpserver: -------------------------------------------------------------------------------- 1 | WSGIDaemonProcess ztpserver user=www-data group=www-data threads=25 2 | WSGIScriptAlias / /etc/ztpserver/ztpserver.wsgi 3 | 4 | 5 | WSGIProcessGroup ztpserver 6 | WSGIApplicationGroup %{GLOBAL} 7 | Order deny,allow 8 | Allow from all 9 | 10 | -------------------------------------------------------------------------------- /Ubuntu/conf/named.conf.local: -------------------------------------------------------------------------------- 1 | // 2 | // Do any local configuration here 3 | // 4 | 5 | // Consider adding the 1918 zones here, if they are not used in your 6 | // organization 7 | //include "/etc/bind/zones.rfc1918"; 8 | 9 | zone "ztps-test.com" { 10 | type master; 11 | file "/etc/bind/zones/db.ztps-test.com"; 12 | }; 13 | 14 | zone "." { 15 | type forward; 16 | forwarders { 8.8.8.8; }; 17 | }; -------------------------------------------------------------------------------- /Fedora/conf/screenrc: -------------------------------------------------------------------------------- 1 | #Generated by Packer and EOS+ 2 | msgminwait 0 3 | msgwait 0 4 | startup_message off 5 | caption splitonly 6 | caption always "%{= gk}%-Lw%{= bW}%50> %n%f* %t %{-}%+Lw%< %= %{= rk} %H %l %{= gk} %0c:%s %{-}" 7 | shelltitle bash 8 | attrcolor u "Y" 9 | attrcolor b "R" 10 | screen 11 | screen 12 | screen 13 | screen 14 | screen 15 | select 0 16 | kill 17 | select 1 18 | msgminwait 1 19 | msgwait 5 20 | scrollback 1024 -------------------------------------------------------------------------------- /Ubuntu/conf/screenrc: -------------------------------------------------------------------------------- 1 | #Generated by Packer and EOS+ 2 | msgminwait 0 3 | msgwait 0 4 | startup_message off 5 | caption splitonly 6 | caption always "%{= gk}%-Lw%{= bW}%50> %n%f* %t %{-}%+Lw%< %= %{= rk} %H %l %{= gk} %0c:%s %{-}" 7 | shelltitle bash 8 | attrcolor u "Y" 9 | attrcolor b "R" 10 | screen 11 | screen 12 | screen 13 | screen 14 | screen 15 | select 0 16 | kill 17 | select 1 18 | msgminwait 1 19 | msgwait 5 20 | scrollback 1024 -------------------------------------------------------------------------------- /Ubuntu/conf/named.conf.default-zones: -------------------------------------------------------------------------------- 1 | // prime the server with knowledge of the root servers 2 | //zone "." { 3 | // type hint; 4 | // file "/etc/bind/db.root"; 5 | //}; 6 | 7 | // be authoritative for the localhost forward and reverse zones, and for 8 | // broadcast zones as per RFC 1912 9 | 10 | //zone "localhost" { 11 | // type master; 12 | // file "/etc/bind/db.local"; 13 | //}; 14 | 15 | //zone "127.in-addr.arpa" { 16 | // type master; 17 | // file "/etc/bind/db.127"; 18 | //}; 19 | 20 | //zone "0.in-addr.arpa" { 21 | // type master; 22 | // file "/etc/bind/db.0"; 23 | //}; 24 | 25 | //zone "255.in-addr.arpa" { 26 | // type master; 27 | // file "/etc/bind/db.255"; 28 | //}; -------------------------------------------------------------------------------- /Ubuntu/conf/ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default 4 | # This is also true if you have upgraded from before 2.2.9-3 (i.e. from 5 | # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and 6 | # README.Debian.gz 7 | 8 | #Just enabling 8080 for ZTPServer 9 | Listen 8080 10 | 11 | #NameVirtualHost *:80 12 | #Listen 80 13 | 14 | # 15 | # If you add NameVirtualHost *:443 here, you will also have to change 16 | # the VirtualHost statement in /etc/apache2/sites-available/default-ssl 17 | # to 18 | # Server Name Indication for SSL named virtual hosts is currently not 19 | # supported by MSIE on Windows XP. 20 | # Listen 443 21 | # 22 | 23 | # 24 | # Listen 443 25 | # -------------------------------------------------------------------------------- /Fedora/conf/ztps-test.com.zone: -------------------------------------------------------------------------------- 1 | $ORIGIN ztps-test.com. 2 | $TTL 86400 3 | @ SOA dns1.ztps-test.com. hostmaster.ztps-test.com. ( 4 | 2014052802 ; serial 5 | 21600 ; refresh after 6 hours 6 | 3600 ; retry after 1 hour 7 | 604800 ; expire after 1 week 8 | 86400 ) ; minimum TTL of 1 day 9 | ; 10 | ; 11 | NS dns1.ztps-test.com. 12 | dns1 A 172.16.130.10 13 | ; 14 | ; 15 | ;@ MX 10 mail.example.com. 16 | ; MX 20 mail2.example.com. 17 | ;mail A 10.0.1.5 18 | ; AAAA aaaa:bbbb::5 19 | ;mail2 A 10.0.1.6 20 | ; AAAA aaaa:bbbb::6 21 | ; 22 | ; 23 | ; This sample zone file illustrates sharing the same IP addresses for multiple services: 24 | ; 25 | ;services A 10.0.1.10 26 | ; AAAA aaaa:bbbb::10 27 | ; A 10.0.1.11 28 | ; AAAA aaaa:bbbb::11 29 | ; 30 | ;ftp CNAME services.example.com. 31 | ;www CNAME services.example.com. 32 | ; 33 | ; 34 | ztps A 172.16.130.10 35 | ;veos1 A 172.16.130.11 36 | ;veos2 A 172.16.130.12 37 | ;veos3 A 172.16.130.13 38 | ;veosmgmt A 172.16.130.14 39 | ; 40 | ;XMPP Services 41 | _xmpp-client._tcp.ztps-test.com. 86400 IN SRV 5 0 5222 im.ztps-test.com. 42 | _xmpp-server._tcp.ztps-test.com. 86400 IN SRV 5 0 5269 im.ztps-test.com. 43 | ; 44 | _xmpp-client._tcp.im.ztps-test.com. 86400 IN SRV 5 0 5222 im.ztps-test.com. 45 | _xmpp-server._tcp.im.ztps-test.com. 86400 IN SRV 5 0 5269 im.ztps-test.com. 46 | ; 47 | im A 172.16.130.10 -------------------------------------------------------------------------------- /Ubuntu/conf/db.ztps-test.com: -------------------------------------------------------------------------------- 1 | $ORIGIN ztps-test.com. 2 | $TTL 86400 3 | @ SOA dns1.ztps-test.com. hostmaster.ztps-test.com. ( 4 | 2014052802 ; serial 5 | 21600 ; refresh after 6 hours 6 | 3600 ; retry after 1 hour 7 | 604800 ; expire after 1 week 8 | 86400 ) ; minimum TTL of 1 day 9 | ; 10 | ; 11 | NS dns1.ztps-test.com. 12 | dns1 A 172.16.130.10 13 | ; 14 | ; 15 | ;@ MX 10 mail.example.com. 16 | ; MX 20 mail2.example.com. 17 | ;mail A 10.0.1.5 18 | ; AAAA aaaa:bbbb::5 19 | ;mail2 A 10.0.1.6 20 | ; AAAA aaaa:bbbb::6 21 | ; 22 | ; 23 | ; This sample zone file illustrates sharing the same IP addresses for multiple services: 24 | ; 25 | ;services A 10.0.1.10 26 | ; AAAA aaaa:bbbb::10 27 | ; A 10.0.1.11 28 | ; AAAA aaaa:bbbb::11 29 | ; 30 | ;ftp CNAME services.example.com. 31 | ;www CNAME services.example.com. 32 | ; 33 | ; 34 | ztps A 172.16.130.10 35 | ;veos1 A 172.16.130.11 36 | ;veos2 A 172.16.130.12 37 | ;veos3 A 172.16.130.13 38 | ;veosmgmt A 172.16.130.14 39 | ; 40 | ;XMPP Services 41 | _xmpp-client._tcp.ztps-test.com. 86400 IN SRV 5 0 5222 im.ztps-test.com. 42 | _xmpp-server._tcp.ztps-test.com. 86400 IN SRV 5 0 5269 im.ztps-test.com. 43 | ; 44 | _xmpp-client._tcp.im.ztps-test.com. 86400 IN SRV 5 0 5222 im.ztps-test.com. 45 | _xmpp-server._tcp.im.ztps-test.com. 86400 IN SRV 5 0 5269 im.ztps-test.com. 46 | ; 47 | im A 172.16.130.10 48 | -------------------------------------------------------------------------------- /Fedora/conf/named.conf: -------------------------------------------------------------------------------- 1 | // 2 | // named.conf 3 | // 4 | // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS 5 | // server as a caching only nameserver (as a localhost DNS resolver only). 6 | // 7 | // See /usr/share/doc/bind*/sample/ for example named configuration files. 8 | // 9 | 10 | options { 11 | listen-on port 53 { 127.0.0.1; }; 12 | listen-on port 53 { 172.16.130.10; }; 13 | listen-on-v6 port 53 { ::1; }; 14 | directory "/var/named"; 15 | dump-file "/var/named/data/cache_dump.db"; 16 | statistics-file "/var/named/data/named_stats.txt"; 17 | memstatistics-file "/var/named/data/named_mem_stats.txt"; 18 | allow-query { any; }; 19 | 20 | /* 21 | - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. 22 | - If you are building a RECURSIVE (caching) DNS server, you need to enable 23 | recursion. 24 | - If your recursive DNS server has a public IP address, you MUST enable access 25 | control to limit queries to your legitimate users. Failing to do so will 26 | cause your server to become part of large scale DNS amplification 27 | attacks. Implementing BCP38 within your network would greatly 28 | reduce such attack surface 29 | */ 30 | recursion yes; 31 | 32 | dnssec-enable no; 33 | dnssec-validation no; 34 | dnssec-lookaside auto; 35 | 36 | /* Path to ISC DLV key */ 37 | bindkeys-file "/etc/named.iscdlv.key"; 38 | 39 | managed-keys-directory "/var/named/dynamic"; 40 | 41 | pid-file "/run/named/named.pid"; 42 | session-keyfile "/run/named/session.key"; 43 | }; 44 | 45 | logging { 46 | channel default_debug { 47 | file "data/named.run"; 48 | severity dynamic; 49 | }; 50 | }; 51 | 52 | zone "ztps-test.com" IN { 53 | type master; 54 | file "ztps-test.com.zone"; 55 | }; 56 | 57 | zone "." { 58 | type forward; 59 | forwarders { 8.8.8.8; }; 60 | }; 61 | -------------------------------------------------------------------------------- /Ubuntu/conf/named.conf: -------------------------------------------------------------------------------- 1 | // 2 | // named.conf 3 | // 4 | // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS 5 | // server as a caching only nameserver (as a localhost DNS resolver only). 6 | // 7 | // See /usr/share/doc/bind*/sample/ for example named configuration files. 8 | // 9 | 10 | options { 11 | listen-on port 53 { 127.0.0.1; }; 12 | listen-on port 53 { 172.16.130.10; }; 13 | listen-on-v6 port 53 { ::1; }; 14 | directory "/var/named"; 15 | dump-file "/var/named/data/cache_dump.db"; 16 | statistics-file "/var/named/data/named_stats.txt"; 17 | memstatistics-file "/var/named/data/named_mem_stats.txt"; 18 | allow-query { any; }; 19 | 20 | /* 21 | - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. 22 | - If you are building a RECURSIVE (caching) DNS server, you need to enable 23 | recursion. 24 | - If your recursive DNS server has a public IP address, you MUST enable access 25 | control to limit queries to your legitimate users. Failing to do so will 26 | cause your server to become part of large scale DNS amplification 27 | attacks. Implementing BCP38 within your network would greatly 28 | reduce such attack surface 29 | */ 30 | recursion yes; 31 | 32 | dnssec-enable no; 33 | dnssec-validation no; 34 | dnssec-lookaside auto; 35 | 36 | /* Path to ISC DLV key */ 37 | bindkeys-file "/etc/named.iscdlv.key"; 38 | 39 | managed-keys-directory "/var/named/dynamic"; 40 | 41 | pid-file "/run/named/named.pid"; 42 | session-keyfile "/run/named/session.key"; 43 | }; 44 | 45 | logging { 46 | channel default_debug { 47 | file "data/named.run"; 48 | severity dynamic; 49 | }; 50 | }; 51 | 52 | zone "ztps-test.com" IN { 53 | type master; 54 | file "ztps-test.com.zone"; 55 | }; 56 | 57 | zone "." { 58 | type forward; 59 | forwarders { 8.8.8.8; }; 60 | }; 61 | -------------------------------------------------------------------------------- /Ubuntu/http/preseed.cfg: -------------------------------------------------------------------------------- 1 | choose-mirror-bin mirror/http/proxy string 2 | d-i base-installer/kernel/override-image string linux-server 3 | d-i clock-setup/utc boolean true 4 | d-i clock-setup/utc-auto boolean true 5 | d-i finish-install/reboot_in_progress note 6 | d-i grub-installer/only_debian boolean true 7 | d-i grub-installer/with_other_os boolean true 8 | d-i partman-auto-lvm/guided_size string max 9 | d-i partman-auto/choose_recipe select atomic 10 | d-i partman-auto/method string lvm 11 | d-i partman-lvm/confirm boolean true 12 | d-i partman-lvm/confirm boolean true 13 | d-i partman-lvm/confirm_nooverwrite boolean true 14 | d-i partman-lvm/device_remove_lvm boolean true 15 | d-i partman/choose_partition select finish 16 | d-i partman/confirm boolean true 17 | d-i partman/confirm_nooverwrite boolean true 18 | d-i partman/confirm_write_new_label boolean true 19 | 20 | #Root User 21 | d-i passwd/root-login boolean true 22 | d-i passwd/root-password password eosplus 23 | d-i passwd/root-password-again password eosplus 24 | 25 | # Default user 26 | d-i passwd/user-fullname string ztpsadmin 27 | d-i passwd/username string ztpsadmin 28 | d-i passwd/user-password password eosplus 29 | d-i passwd/user-password-again password eosplus 30 | 31 | #Network Configuration 32 | # If you prefer to configure the network manually, uncomment this line and 33 | # the static network configuration below. 34 | #d-i netcfg/disable_autoconfig boolean false 35 | #d-i netcfg/choose_interface select auto 36 | d-i netcfg/get_hostname string ztps 37 | d-i netcfg/get_domain ztps-test.com 38 | 39 | # Minimum packages 40 | d-i pkgsel/include string openssh-server 41 | d-i pkgsel/install-language-support boolean false 42 | d-i pkgsel/update-policy select none 43 | d-i pkgsel/upgrade select none 44 | 45 | d-i time/zone string US/Eastern 46 | d-i user-setup/allow-password-weak boolean true 47 | d-i user-setup/encrypt-home boolean false 48 | tasksel tasksel/first multiselect standard, ubuntu-server 49 | -------------------------------------------------------------------------------- /Fedora/conf/ntp.conf: -------------------------------------------------------------------------------- 1 | # For more information about this file, see the man pages 2 | # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). 3 | 4 | driftfile /var/lib/ntp/drift 5 | 6 | # Permit time synchronization with our time source, but do not 7 | # permit the source to query or modify the service on this system. 8 | restrict default kod nomodify notrap nopeer noquery 9 | 10 | # Permit all access over the loopback interface. This could 11 | # be tightened as well, but to do so would effect some of 12 | # the administrative functions. 13 | restrict 127.0.0.1 14 | restrict ::1 15 | restrict 172.16.0.0 mask 255.255.0.0 nomodify notrap 16 | 17 | # Hosts on local network are less restricted. 18 | #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 19 | 20 | # Use public servers from the pool.ntp.org project. 21 | # Please consider joining the pool (http://www.pool.ntp.org/join.html). 22 | server 0.fedora.pool.ntp.org iburst 23 | server 1.fedora.pool.ntp.org iburst 24 | server 2.fedora.pool.ntp.org iburst 25 | server 3.fedora.pool.ntp.org iburst 26 | 27 | #broadcast 192.168.1.255 autokey # broadcast server 28 | #broadcastclient # broadcast client 29 | #broadcast 224.0.1.1 autokey # multicast server 30 | #multicastclient 224.0.1.1 # multicast client 31 | #manycastserver 239.255.254.254 # manycast server 32 | #manycastclient 239.255.254.254 autokey # manycast client 33 | 34 | # Enable public key cryptography. 35 | #crypto 36 | 37 | includefile /etc/ntp/crypto/pw 38 | 39 | # Key file containing the keys and key identifiers used when operating 40 | # with symmetric key cryptography. 41 | keys /etc/ntp/keys 42 | 43 | # Specify the key identifiers which are trusted. 44 | #trustedkey 4 8 42 45 | 46 | # Specify the key identifier to use with the ntpdc utility. 47 | #requestkey 8 48 | 49 | # Specify the key identifier to use with the ntpq utility. 50 | #controlkey 8 51 | 52 | # Enable writing of statistics records. 53 | #statistics clockstats cryptostats loopstats peerstats 54 | -------------------------------------------------------------------------------- /Ubuntu/conf/ntp.conf: -------------------------------------------------------------------------------- 1 | # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help 2 | 3 | driftfile /var/lib/ntp/ntp.drift 4 | 5 | 6 | # Enable this if you want statistics to be logged. 7 | #statsdir /var/log/ntpstats/ 8 | 9 | statistics loopstats peerstats clockstats 10 | filegen loopstats file loopstats type day enable 11 | filegen peerstats file peerstats type day enable 12 | filegen clockstats file clockstats type day enable 13 | 14 | # Specify one or more NTP servers. 15 | 16 | # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board 17 | # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for 18 | # more information. 19 | server 0.ubuntu.pool.ntp.org 20 | server 1.ubuntu.pool.ntp.org 21 | server 2.ubuntu.pool.ntp.org 22 | server 3.ubuntu.pool.ntp.org 23 | 24 | # Use Ubuntu's ntp server as a fallback. 25 | server ntp.ubuntu.com 26 | 27 | # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for 28 | # details. The web page 29 | # might also be helpful. 30 | # 31 | # Note that "restrict" applies to both servers and clients, so a configuration 32 | # that might be intended to block requests from certain clients could also end 33 | # up blocking replies from your own upstream servers. 34 | 35 | # By default, exchange time with everybody, but don't allow configuration. 36 | restrict -4 default kod notrap nomodify nopeer noquery 37 | restrict -6 default kod notrap nomodify nopeer noquery 38 | 39 | # Local users may interrogate the ntp server more closely. 40 | restrict 127.0.0.1 41 | restrict ::1 42 | restrict 172.16.0.0 mask 255.255.0.0 nomodify notrap 43 | 44 | # Clients from this (example!) subnet have unlimited access, but only if 45 | # cryptographically authenticated. 46 | #restrict 192.168.123.0 mask 255.255.255.0 notrust 47 | 48 | 49 | # If you want to provide time to your local subnet, change the next line. 50 | # (Again, the address is an example only.) 51 | #broadcast 192.168.123.255 52 | 53 | # If you want to listen to time broadcasts on your local subnet, de-comment the 54 | # next lines. Please do this only if you trust everybody on the network! 55 | #disable auth 56 | #broadcastclient 57 | -------------------------------------------------------------------------------- /Fedora/http/ks-32b.cfg: -------------------------------------------------------------------------------- 1 | #version=DEVEL 2 | # System authorization information 3 | auth --enableshadow --passalgo=sha512 4 | 5 | # Run the Setup Agent on first boot 6 | firstboot --enable 7 | ignoredisk --only-use=sda 8 | 9 | # Keyboard layouts 10 | keyboard --vckeymap=us --xlayouts='us' 11 | 12 | # System language 13 | lang en_US.UTF-8 14 | 15 | # Network information 16 | #network --bootproto=dhcp --device=eth0 --ipv6=auto --activate 17 | #network --hostname=localhost.localdomain 18 | 19 | # Network information 20 | network --device=eth0 --bootproto=dhcp --noipv6 --activate 21 | # network --device=eth0 --bootproto=static --ip=10.0.0.2 --gateway=10.0.0.1 --netmask=255.255.255.0 --noipv6 --activate 22 | # network --hostname=ztps 23 | 24 | # Root password 25 | rootpw --iscrypted $6$ghGKBQztYlSPojBU$BOCLySgGNphtazAWqd2VfPO852JZP2YoF68HgKXD7eJzqGl0F7/4EeKPvbBrawMpnfhppsoR9ZuBPwUEGU01g0 26 | 27 | # System timezone 28 | timezone America/New_York --isUtc 29 | user --groups=wheel --homedir=/home/ztpsadmin --name=ztpsadmin --password=$6$ol2NBD.k9UZjKBah$psJWGgQc617BTlfdESsBI/mEfplx/BVAqGu/l4uQdcBuyixunGP1KXANqLaVG8VNfqBnIm5cKyzAeccEjlO6Z. --iscrypted --gecos="ztpsadmin" 30 | 31 | # System bootloader configuration 32 | bootloader --extlinux 33 | autopart --type=plain 34 | 35 | # Partition clearing information 36 | clearpart --all --initlabel 37 | 38 | # Use network installation 39 | url --url=https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/ 40 | 41 | # Reboot after installation 42 | reboot 43 | 44 | ############################################################################### 45 | # PACKAGE SELECTION # 46 | ############################################################################### 47 | 48 | %packages --excludedocs 49 | @core 50 | 51 | # Note that the @core group is always selected by default, 52 | # so it is not specified here. 53 | 54 | # Turn off host-only initramfs image generation (for image portability) 55 | dracut-config-generic 56 | 57 | # Turn off (unnecessary) rescue image generation 58 | -dracut-config-rescue 59 | 60 | 61 | %end 62 | 63 | ################################### 64 | # POST-INSTALLATION SCRIPT 65 | ################################### 66 | 67 | %post --erroronfail 68 | 69 | #Let packer handle the rest 70 | 71 | %end 72 | -------------------------------------------------------------------------------- /Fedora/http/ks-net.cfg: -------------------------------------------------------------------------------- 1 | #version=DEVEL 2 | # System authorization information 3 | auth --enableshadow --passalgo=sha512 4 | 5 | # Run the Setup Agent on first boot 6 | firstboot --enable 7 | ignoredisk --only-use=sda 8 | 9 | # Keyboard layouts 10 | keyboard --vckeymap=us --xlayouts='us' 11 | 12 | # System language 13 | lang en_US.UTF-8 14 | 15 | # Network information 16 | #network --bootproto=dhcp --device=eth0 --ipv6=auto --activate 17 | #network --hostname=localhost.localdomain 18 | 19 | # Network information 20 | network --device=eth0 --bootproto=dhcp --noipv6 --activate 21 | network --device=eth1 --bootproto=static --ip=172.16.130.10 --netmask=255.255.255.0 --gateway=172.16.130.1 --nameserver=172.16.130.10 --noipv6 --activate 22 | network --hostname=ztps.ztps-test.com 23 | 24 | # Root password 25 | rootpw --iscrypted $6$ghGKBQztYlSPojBU$BOCLySgGNphtazAWqd2VfPO852JZP2YoF68HgKXD7eJzqGl0F7/4EeKPvbBrawMpnfhppsoR9ZuBPwUEGU01g0 26 | 27 | # System timezone 28 | timezone America/New_York --isUtc 29 | user --groups=wheel --homedir=/home/ztpsadmin --name=ztpsadmin --password=$6$ol2NBD.k9UZjKBah$psJWGgQc617BTlfdESsBI/mEfplx/BVAqGu/l4uQdcBuyixunGP1KXANqLaVG8VNfqBnIm5cKyzAeccEjlO6Z. --iscrypted --gecos="ztpsadmin" 30 | 31 | # System bootloader configuration 32 | bootloader --extlinux 33 | autopart --type=plain 34 | 35 | 36 | # Partition clearing information 37 | clearpart --all --initlabel 38 | 39 | # Use network installation 40 | url --url=https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/ 41 | 42 | # Reboot after installation 43 | reboot 44 | 45 | ############################################################################### 46 | # PACKAGE SELECTION # 47 | ############################################################################### 48 | 49 | %packages 50 | 51 | # Note that the @core group is always selected by default, 52 | # so it is not specified here. 53 | 54 | # Turn off host-only initramfs image generation (for image portability) 55 | dracut-config-generic 56 | 57 | # Turn off (unnecessary) rescue image generation 58 | -dracut-config-rescue 59 | 60 | 61 | %end 62 | 63 | ################################### 64 | # POST-INSTALLATION SCRIPT 65 | ################################### 66 | 67 | %post --erroronfail 68 | 69 | #Let's let packer handle the rest 70 | 71 | %end 72 | -------------------------------------------------------------------------------- /Fedora/conf/rsyslog.conf: -------------------------------------------------------------------------------- 1 | # rsyslog configuration file 2 | 3 | # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html 4 | # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html 5 | 6 | #### MODULES #### 7 | 8 | # The imjournal module bellow is now used as a message source instead of imuxsock. 9 | $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) 10 | $ModLoad imjournal # provides access to the systemd journal 11 | $ModLoad imklog # provides kernel logging support (previously done by rklogd) 12 | #$ModLoad immark # provides --MARK-- message capability 13 | 14 | # Provides UDP syslog reception 15 | $ModLoad imudp 16 | $UDPServerRun 514 17 | 18 | # Provides TCP syslog reception 19 | $ModLoad imtcp 20 | $InputTCPServerRun 514 21 | 22 | 23 | #### GLOBAL DIRECTIVES #### 24 | 25 | # Where to place auxiliary files 26 | $WorkDirectory /var/lib/rsyslog 27 | 28 | # Use default timestamp format 29 | $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat 30 | 31 | # File syncing capability is disabled by default. This feature is usually not required, 32 | # not useful and an extreme performance hit 33 | #$ActionFileEnableSync on 34 | 35 | # Include all config files in /etc/rsyslog.d/ 36 | $IncludeConfig /etc/rsyslog.d/*.conf 37 | 38 | # Turn off message reception via local log socket; 39 | # local messages are retrieved through imjournal now. 40 | $OmitLocalLogging on 41 | 42 | # File to store the position in the journal 43 | $IMJournalStateFile imjournal.state 44 | 45 | 46 | #### RULES #### 47 | 48 | # Log all kernel messages to the console. 49 | # Logging much else clutters up the screen. 50 | #kern.* /dev/console 51 | 52 | # Log anything (except mail) of level info or higher. 53 | # Don't log private authentication messages! 54 | *.info;mail.none;authpriv.none;cron.none /var/log/messages 55 | 56 | # The authpriv file has restricted access. 57 | authpriv.* /var/log/secure 58 | 59 | # Log all the mail messages in one place. 60 | mail.* -/var/log/maillog 61 | 62 | 63 | # Log cron stuff 64 | cron.* /var/log/cron 65 | 66 | # Everybody gets emergency messages 67 | *.emerg :omusrmsg:* 68 | 69 | # Save news errors of level crit and higher in a special file. 70 | uucp,news.crit /var/log/spooler 71 | 72 | # Save boot messages also to boot.log 73 | local7.* /var/log/boot.log 74 | 75 | 76 | # ### begin forwarding rule ### 77 | # The statement between the begin ... end define a SINGLE forwarding 78 | # rule. They belong together, do NOT split them. If you create multiple 79 | # forwarding rules, duplicate the whole block! 80 | # Remote Logging (we use TCP for reliable delivery) 81 | # 82 | # An on-disk queue is created for this action. If the remote host is 83 | # down, messages are spooled to disk and sent when it is up again. 84 | #$ActionQueueFileName fwdRule1 # unique name prefix for spool files 85 | #$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) 86 | #$ActionQueueSaveOnShutdown on # save messages to disk on shutdown 87 | #$ActionQueueType LinkedList # run asynchronously 88 | #$ActionResumeRetryCount -1 # infinite retries if host is down 89 | # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional 90 | #*.* @@remote-host:514 91 | # ### end of the forwarding rule ### -------------------------------------------------------------------------------- /Ubuntu/conf/rsyslog.conf: -------------------------------------------------------------------------------- 1 | # rsyslog configuration file 2 | 3 | # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html 4 | # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html 5 | 6 | #### MODULES #### 7 | 8 | # The imjournal module bellow is now used as a message source instead of imuxsock. 9 | $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) 10 | $ModLoad imjournal # provides access to the systemd journal 11 | $ModLoad imklog # provides kernel logging support (previously done by rklogd) 12 | #$ModLoad immark # provides --MARK-- message capability 13 | 14 | # Provides UDP syslog reception 15 | $ModLoad imudp 16 | $UDPServerRun 514 17 | 18 | # Provides TCP syslog reception 19 | $ModLoad imtcp 20 | $InputTCPServerRun 514 21 | 22 | 23 | #### GLOBAL DIRECTIVES #### 24 | 25 | # Where to place auxiliary files 26 | $WorkDirectory /var/lib/rsyslog 27 | 28 | # Use default timestamp format 29 | $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat 30 | 31 | # File syncing capability is disabled by default. This feature is usually not required, 32 | # not useful and an extreme performance hit 33 | #$ActionFileEnableSync on 34 | 35 | # Include all config files in /etc/rsyslog.d/ 36 | $IncludeConfig /etc/rsyslog.d/*.conf 37 | 38 | # Turn off message reception via local log socket; 39 | # local messages are retrieved through imjournal now. 40 | $OmitLocalLogging on 41 | 42 | # File to store the position in the journal 43 | $IMJournalStateFile imjournal.state 44 | 45 | 46 | #### RULES #### 47 | 48 | # Log all kernel messages to the console. 49 | # Logging much else clutters up the screen. 50 | #kern.* /dev/console 51 | 52 | # Log anything (except mail) of level info or higher. 53 | # Don't log private authentication messages! 54 | *.info;mail.none;authpriv.none;cron.none /var/log/messages 55 | 56 | # The authpriv file has restricted access. 57 | authpriv.* /var/log/secure 58 | 59 | # Log all the mail messages in one place. 60 | mail.* -/var/log/maillog 61 | 62 | 63 | # Log cron stuff 64 | cron.* /var/log/cron 65 | 66 | # Everybody gets emergency messages 67 | *.emerg :omusrmsg:* 68 | 69 | # Save news errors of level crit and higher in a special file. 70 | uucp,news.crit /var/log/spooler 71 | 72 | # Save boot messages also to boot.log 73 | local7.* /var/log/boot.log 74 | 75 | 76 | # ### begin forwarding rule ### 77 | # The statement between the begin ... end define a SINGLE forwarding 78 | # rule. They belong together, do NOT split them. If you create multiple 79 | # forwarding rules, duplicate the whole block! 80 | # Remote Logging (we use TCP for reliable delivery) 81 | # 82 | # An on-disk queue is created for this action. If the remote host is 83 | # down, messages are spooled to disk and sent when it is up again. 84 | #$ActionQueueFileName fwdRule1 # unique name prefix for spool files 85 | #$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) 86 | #$ActionQueueSaveOnShutdown on # save messages to disk on shutdown 87 | #$ActionQueueType LinkedList # run asynchronously 88 | #$ActionResumeRetryCount -1 # infinite retries if host is down 89 | # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional 90 | #*.* @@remote-host:514 91 | # ### end of the forwarding rule ### -------------------------------------------------------------------------------- /Fedora/conf/dhcpd.conf: -------------------------------------------------------------------------------- 1 | #dhcp.conf 2 | #Based off of the sample file in /usr/share/doc/dhcp... 3 | #Modified by Phil DiLeo - 20140529 4 | 5 | # option definitions common to all supported networks... 6 | #option domain-name "example.org"; 7 | #option domain-name-servers ns1.example.org, ns2.example.org; 8 | 9 | #default-lease-time 600; 10 | #max-lease-time 7200; 11 | 12 | # Use this to enble / disable dynamic dns updates globally. 13 | #ddns-update-style none; 14 | 15 | # If this DHCP server is the official DHCP server for the local 16 | # network, the authoritative directive should be uncommented. 17 | #authoritative; 18 | 19 | # Use this to send dhcp log messages to a different log file (you also 20 | # have to hack syslog.conf to complete the redirection). 21 | log-facility local7; 22 | 23 | # No service will be given on this subnet, but declaring it helps the 24 | # DHCP server to understand the network topology. 25 | 26 | #subnet 172.16.130.0 netmask 255.255.255.0 { 27 | #} 28 | 29 | # This is a very basic subnet declaration. 30 | 31 | #subnet 10.254.239.0 netmask 255.255.255.224 { 32 | # range 10.254.239.10 10.254.239.20; 33 | # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; 34 | #} 35 | 36 | # This declaration allows BOOTP clients to get dynamic addresses, 37 | # which we don't really recommend. 38 | 39 | #subnet 10.254.239.32 netmask 255.255.255.224 { 40 | # range dynamic-bootp 10.254.239.40 10.254.239.60; 41 | # option broadcast-address 10.254.239.31; 42 | # option routers rtr-239-32-1.example.org; 43 | #} 44 | 45 | # A slightly different configuration for an internal subnet. 46 | #subnet 10.5.5.0 netmask 255.255.255.224 { 47 | # range 10.5.5.26 10.5.5.30; 48 | # option domain-name-servers ns1.internal.example.org; 49 | # option domain-name "internal.example.org"; 50 | # option routers 10.5.5.1; 51 | # option broadcast-address 10.5.5.31; 52 | # default-lease-time 600; 53 | # max-lease-time 7200; 54 | #} 55 | 56 | # Hosts which require special configuration options can be listed in 57 | # host statements. If no address is specified, the address will be 58 | # allocated dynamically (if possible), but the host-specific information 59 | # will still come from the host declaration. 60 | 61 | #host passacaglia { 62 | # hardware ethernet 0:0:c0:5d:bd:95; 63 | # filename "vmunix.passacaglia"; 64 | # server-name "toccata.fugue.com"; 65 | #} 66 | 67 | # Fixed IP addresses can also be specified for hosts. These addresses 68 | # should not also be listed as being available for dynamic assignment. 69 | # Hosts for which fixed IP addresses have been specified can boot using 70 | # BOOTP or DHCP. Hosts for which no fixed address is specified can only 71 | # be booted with DHCP, unless there is an address range on the subnet 72 | # to which a BOOTP client is connected which has the dynamic-bootp flag 73 | # set. 74 | #host fantasia { 75 | # hardware ethernet 08:00:07:26:c0:a5; 76 | # fixed-address fantasia.fugue.com; 77 | #} 78 | 79 | # You can declare a class of clients and then do address allocation 80 | # based on that. The example below shows a case where all clients 81 | # in a certain class get addresses on the 10.17.224/24 subnet, and all 82 | # other clients get addresses on the 10.0.29/24 subnet. 83 | 84 | #class "foo" { 85 | # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; 86 | #} 87 | 88 | #shared-network 224-29 { 89 | # subnet 10.17.224.0 netmask 255.255.255.0 { 90 | # option routers rtr-224.example.org; 91 | # } 92 | # subnet 10.0.29.0 netmask 255.255.255.0 { 93 | # option routers rtr-29.example.org; 94 | # } 95 | # pool { 96 | # allow members of "foo"; 97 | # range 10.17.224.10 10.17.224.250; 98 | # } 99 | # pool { 100 | # deny members of "foo"; 101 | # range 10.0.29.10 10.0.29.230; 102 | # } 103 | #} 104 | 105 | 106 | #Subnet created for VEOS devices 107 | subnet 172.16.130.0 netmask 255.255.255.0 { 108 | range 172.16.130.100 172.16.130.254; 109 | option domain-name-servers 172.16.130.10; 110 | option domain-name "ztps-test.com"; 111 | option routers 172.16.130.2; 112 | option broadcast-address 172.16.130.255; 113 | option bootfile-name "http://ztps.ztps-test.com:8080/bootstrap"; 114 | default-lease-time 86400; 115 | max-lease-time 86400; 116 | } -------------------------------------------------------------------------------- /Ubuntu/conf/dhcpd.conf: -------------------------------------------------------------------------------- 1 | #dhcp.conf 2 | #Based off of the sample file in /usr/share/doc/dhcp... 3 | #Modified by Phil DiLeo - 20140529 4 | 5 | # option definitions common to all supported networks... 6 | #option domain-name "example.org"; 7 | #option domain-name-servers ns1.example.org, ns2.example.org; 8 | 9 | #default-lease-time 600; 10 | #max-lease-time 7200; 11 | 12 | # Use this to enble / disable dynamic dns updates globally. 13 | #ddns-update-style none; 14 | 15 | # If this DHCP server is the official DHCP server for the local 16 | # network, the authoritative directive should be uncommented. 17 | #authoritative; 18 | 19 | # Use this to send dhcp log messages to a different log file (you also 20 | # have to hack syslog.conf to complete the redirection). 21 | log-facility local7; 22 | 23 | # No service will be given on this subnet, but declaring it helps the 24 | # DHCP server to understand the network topology. 25 | 26 | #subnet 172.16.130.0 netmask 255.255.255.0 { 27 | #} 28 | 29 | # This is a very basic subnet declaration. 30 | 31 | #subnet 10.254.239.0 netmask 255.255.255.224 { 32 | # range 10.254.239.10 10.254.239.20; 33 | # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; 34 | #} 35 | 36 | # This declaration allows BOOTP clients to get dynamic addresses, 37 | # which we don't really recommend. 38 | 39 | #subnet 10.254.239.32 netmask 255.255.255.224 { 40 | # range dynamic-bootp 10.254.239.40 10.254.239.60; 41 | # option broadcast-address 10.254.239.31; 42 | # option routers rtr-239-32-1.example.org; 43 | #} 44 | 45 | # A slightly different configuration for an internal subnet. 46 | #subnet 10.5.5.0 netmask 255.255.255.224 { 47 | # range 10.5.5.26 10.5.5.30; 48 | # option domain-name-servers ns1.internal.example.org; 49 | # option domain-name "internal.example.org"; 50 | # option routers 10.5.5.1; 51 | # option broadcast-address 10.5.5.31; 52 | # default-lease-time 600; 53 | # max-lease-time 7200; 54 | #} 55 | 56 | # Hosts which require special configuration options can be listed in 57 | # host statements. If no address is specified, the address will be 58 | # allocated dynamically (if possible), but the host-specific information 59 | # will still come from the host declaration. 60 | 61 | #host passacaglia { 62 | # hardware ethernet 0:0:c0:5d:bd:95; 63 | # filename "vmunix.passacaglia"; 64 | # server-name "toccata.fugue.com"; 65 | #} 66 | 67 | # Fixed IP addresses can also be specified for hosts. These addresses 68 | # should not also be listed as being available for dynamic assignment. 69 | # Hosts for which fixed IP addresses have been specified can boot using 70 | # BOOTP or DHCP. Hosts for which no fixed address is specified can only 71 | # be booted with DHCP, unless there is an address range on the subnet 72 | # to which a BOOTP client is connected which has the dynamic-bootp flag 73 | # set. 74 | #host fantasia { 75 | # hardware ethernet 08:00:07:26:c0:a5; 76 | # fixed-address fantasia.fugue.com; 77 | #} 78 | 79 | # You can declare a class of clients and then do address allocation 80 | # based on that. The example below shows a case where all clients 81 | # in a certain class get addresses on the 10.17.224/24 subnet, and all 82 | # other clients get addresses on the 10.0.29/24 subnet. 83 | 84 | #class "foo" { 85 | # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; 86 | #} 87 | 88 | #shared-network 224-29 { 89 | # subnet 10.17.224.0 netmask 255.255.255.0 { 90 | # option routers rtr-224.example.org; 91 | # } 92 | # subnet 10.0.29.0 netmask 255.255.255.0 { 93 | # option routers rtr-29.example.org; 94 | # } 95 | # pool { 96 | # allow members of "foo"; 97 | # range 10.17.224.10 10.17.224.250; 98 | # } 99 | # pool { 100 | # deny members of "foo"; 101 | # range 10.0.29.10 10.0.29.230; 102 | # } 103 | #} 104 | 105 | 106 | #Subnet created for VEOS devices 107 | subnet 172.16.130.0 netmask 255.255.255.0 { 108 | range 172.16.130.100 172.16.130.254; 109 | option domain-name-servers 172.16.130.10; 110 | option domain-name "ztps-test.com"; 111 | option routers 172.16.130.2; 112 | option broadcast-address 172.16.130.255; 113 | option bootfile-name "http://ztps.ztps-test.com:8080/bootstrap"; 114 | default-lease-time 86400; 115 | max-lease-time 86400; 116 | } -------------------------------------------------------------------------------- /Fedora/ztps-fedora_20_i386.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "ram": "1024", 4 | "disk-size": "4000", 5 | "name": "ztps-fedora-20-i386-eos", 6 | "esxi-user": "", 7 | "esxi-passwd": "", 8 | "esxi-host": "", 9 | "esxi-path": "", 10 | "esxi-network": "" 11 | }, 12 | "builders": [ 13 | { 14 | "boot_command": [ 15 | "", 16 | "", 17 | "vmlinuz ", 18 | "initrd=initrd.img ", 19 | "biosdevname=0 ", 20 | "net.ifnames=0 ", 21 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-32b.cfg", 22 | "" 23 | ], 24 | "boot_wait": "10s", 25 | "disk_size": "{{user `disk-size`}}", 26 | "disk_type_id": "0", 27 | "output_directory":"{{user `name`}}-vmware", 28 | "type": "vmware-iso", 29 | "name": "vmware-iso-eos", 30 | "iso_checksum": "f9a2f536d9b87a5c403ecbe9113b9c4a32d2d31cb0a9c0944753807dfd3aef2a", 31 | "iso_checksum_type": "sha256", 32 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/i386/iso/Fedora-20-i386-netinst.iso", 33 | "ssh_username": "root", 34 | "ssh_password":"eosplus", 35 | "ssh_port":"22", 36 | "ssh_wait_timeout": "20m", 37 | "guest_os_type": "otherlinux", 38 | "vm_name":"{{user `name`}}", 39 | "vmx_data": { 40 | "memsize": "{{user `ram`}}", 41 | "numvcpus": "1", 42 | "cpuid.coresPerSocket": "1", 43 | "ethernet0.present" : "TRUE", 44 | "ethernet0.virtualdev" : "e1000", 45 | "ethernet0.connectionType" : "nat", 46 | "ethernet0.startConnected" : "TRUE", 47 | "ethernet0.pcislotnumber" : "32" 48 | }, 49 | "shutdown_command": "/sbin/shutdown -h now", 50 | "http_directory":"http/" 51 | }, 52 | { 53 | "boot_command": [ 54 | "", 55 | "", 56 | "vmlinuz ", 57 | "initrd=initrd.img ", 58 | "biosdevname=0 ", 59 | "net.ifnames=0 ", 60 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-32b.cfg", 61 | "" 62 | ], 63 | "boot_wait": "10s", 64 | "disk_size": "{{user `disk-size`}}", 65 | "disk_type_id": "thin", 66 | "output_directory":"{{user `name`}}-vmware", 67 | "type": "vmware-iso", 68 | "name": "esxi-iso-eos", 69 | "headless":"False", 70 | "iso_checksum": "f9a2f536d9b87a5c403ecbe9113b9c4a32d2d31cb0a9c0944753807dfd3aef2a", 71 | "iso_checksum_type": "sha256", 72 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/i386/iso/Fedora-20-i386-netinst.iso", 73 | "ssh_username": "root", 74 | "ssh_password":"eosplus", 75 | "ssh_port":"22", 76 | "ssh_wait_timeout": "20m", 77 | "guest_os_type": "otherlinux", 78 | "vm_name":"{{user `name`}}", 79 | "remote_host":"{{user `esxi-host`}}", 80 | "remote_datastore":"{{user `esxi-path`}}", 81 | "remote_type":"esx5", 82 | "remote_username":"{{user `esxi-user`}}", 83 | "remote_password":"{{user `esxi-passwd`}}", 84 | "vmx_data": { 85 | "memsize": "{{user `ram`}}", 86 | "numvcpus": "1", 87 | "cpuid.coresPerSocket": "1", 88 | "RemoteDisplay.vnc.enabled" : "TRUE", 89 | "ethernet0.startConnected": "TRUE", 90 | "ethernet0.connectiontype" : "custom", 91 | "ethernet0.virtualDev" : "e1000", 92 | "ethernet0.networkName" : "{{user `esxi-network`}}", 93 | "ethernet0.linkstatepropagation.enable" : "TRUE", 94 | "ethernet0.present" : "TRUE", 95 | "ethernet0.pcislotnumber" : "32" 96 | }, 97 | "shutdown_command": "/sbin/shutdown -h now", 98 | "http_directory":"http/" 99 | }, 100 | { 101 | "boot_command": [ 102 | "", 103 | "", 104 | "vmlinuz ", 105 | "initrd=initrd.img ", 106 | "biosdevname=0 ", 107 | "net.ifnames=0 ", 108 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-32b.cfg", 109 | "" 110 | ], 111 | "boot_wait": "10s", 112 | "disk_size": "{{user `disk-size`}}", 113 | "output_directory":"{{user `name`}}-vbox", 114 | "type": "virtualbox-iso", 115 | "name": "virtualbox-iso-eos", 116 | "iso_checksum": "f9a2f536d9b87a5c403ecbe9113b9c4a32d2d31cb0a9c0944753807dfd3aef2a", 117 | "iso_checksum_type": "sha256", 118 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/i386/iso/Fedora-20-i386-netinst.iso", 119 | "ssh_username": "root", 120 | "ssh_password":"eosplus", 121 | "ssh_port":"22", 122 | "ssh_wait_timeout": "20m", 123 | "guest_os_type": "Fedora", 124 | "vm_name":"{{user `name`}}", 125 | "vboxmanage": [ 126 | [ 127 | "modifyvm", 128 | "{{.Name}}", 129 | "--memory", 130 | "{{user `ram`}}" 131 | ], 132 | [ 133 | "modifyvm", 134 | "{{.Name}}", 135 | "--cpus", 136 | "1" 137 | ], 138 | [ 139 | "modifyvm", 140 | "{{.Name}}", 141 | "--rtcuseutc", 142 | "on" 143 | ], 144 | [ 145 | "modifyvm", 146 | "{{.Name}}", 147 | "--bioslogodisplaytime", 148 | "1" 149 | ], 150 | [ 151 | "modifyvm", 152 | "{{.Name}}", 153 | "--nic1", 154 | "nat" 155 | ] 156 | ], 157 | "shutdown_command": "/sbin/shutdown -h now", 158 | "http_directory":"http/" 159 | } 160 | ], 161 | "provisioners": [ 162 | { 163 | "source": "conf", 164 | "destination": "/tmp/packer", 165 | "type":"file" 166 | }, 167 | { 168 | "source": "files", 169 | "destination": "/tmp/packer", 170 | "type":"file" 171 | }, 172 | { 173 | "scripts": [ 174 | "scripts/setup-32b.sh" 175 | ], 176 | "type" : "shell" 177 | } 178 | ] 179 | } 180 | -------------------------------------------------------------------------------- /Ubuntu/scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | # grab any updates and cleanup 4 | apt-get clean 5 | rm -rf /var/lib/apt/lists/* 6 | rm -rf /var/lib/apt/lists/partial/* 7 | apt-get clean 8 | apt-get -y update 9 | apt-get -y upgrade 10 | 11 | # install ztps-related related packages 12 | apt-get -y install python-dev 13 | apt-get -y install python-pip 14 | apt-get -y install libapache2-mod-wsgi 15 | apt-get -y install libyaml-dev 16 | apt-get -y install screen 17 | apt-get -y install git 18 | apt-get -y install lldpad 19 | apt-get -y install apache2 20 | apt-get -y install isc-dhcp-server 21 | apt-get -y install bind9 dnsutils 22 | apt-get -y install ejabberd 23 | apt-get -y install ntp 24 | 25 | # add ztpsadmin to sudo group 26 | adduser ztpsadmin sudo 27 | 28 | ###################################### 29 | # CONFIGURE FIREWALL 30 | ###################################### 31 | # disable UFW 32 | ufw disable 33 | ufw status 34 | ifconfig 35 | 36 | echo "auto eth1 37 | iface eth1 inet static 38 | address 172.16.130.10 39 | netmask 255.255.255.0 40 | " >> /etc/network/interfaces 41 | ifup eth1 42 | 43 | ###################################### 44 | # CONFIGURE LLDP 45 | ###################################### 46 | service lldpad start 47 | lldptool -L -i eth1 adminStatus=rxtx 48 | lldptool -T -i eth1 -V sysName enableTx=yes 49 | lldptool -T -i eth1 -V sysDesc enableTx=yes 50 | 51 | ###################################### 52 | # CONFIGURE SCREEN 53 | ###################################### 54 | cp /tmp/packer/screenrc /home/ztpsadmin/.screenrc 55 | cp /tmp/packer/screenrc /root/.screenrc 56 | 57 | ###################################### 58 | # CONFIGURE ntp 59 | ###################################### 60 | cp /tmp/packer/ntp.conf /etc/ntp.conf 61 | service ntp restart 62 | 63 | ###################################### 64 | # CONFIGURE rsyslog 65 | ###################################### 66 | mv /etc/rsyslog.conf /etc/rsyslog.conf.bak 67 | cp /tmp/packer/rsyslog.conf /etc/rsyslog.conf 68 | service rsyslog restart 69 | netstat -tuplen | grep syslog 70 | 71 | ###################################### 72 | # CONFIGURE eJabberd 73 | ###################################### 74 | mv /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberd.cfg.bak 75 | cp /tmp/packer/ejabberd.cfg /etc/ejabberd/ejabberd.cfg 76 | echo -e "127.0.0.1 ztps ztps.ztps-test.com" >> /etc/hosts 77 | service ejabberd restart 78 | sleep 3 79 | ejabberdctl register cvx im.ztps-test.com eosplus 80 | ejabberdctl register ztpsadmin im.ztps-test.com eosplus 81 | ejabberdctl register bootstrap im.ztps-test.com eosplus 82 | ejabberdctl register veos-dc1-pod1-tor1 im.ztps-test.com eosplus 83 | ejabberdctl register veos-dc1-pod1-tor2 im.ztps-test.com eosplus 84 | ejabberdctl register veos-dc1-pod1-tor3 im.ztps-test.com eosplus 85 | ejabberdctl register veos-dc1-pod1-tor4 im.ztps-test.com eosplus 86 | ejabberdctl register veos-dc1-pod1-tor5 im.ztps-test.com eosplus 87 | ejabberdctl register veos-dc1-pod1-tor6 im.ztps-test.com eosplus 88 | ejabberdctl register veos-dc1-pod1-spine1 im.ztps-test.com eosplus 89 | ejabberdctl register veos-dc1-pod1-spine2 im.ztps-test.com eosplus 90 | ejabberdctl register veos-dc1-pod1-spine3 im.ztps-test.com eosplus 91 | ejabberdctl register veos-dc1-pod1-spine4 im.ztps-test.com eosplus 92 | service ejabberd restart 93 | sleep 6 94 | ejabberdctl status 95 | 96 | ###################################### 97 | # CONFIGURE APACHE 98 | ###################################### 99 | mv /etc/apache2/ports.conf /etc/apache2/ports.conf.bak 100 | cp /tmp/packer/ports.conf /etc/apache2/ports.conf 101 | 102 | rm /etc/apache2/sites-enabled/000-default 103 | cp /tmp/packer/001-ztpserver /etc/apache2/sites-enabled/001-ztpserver 104 | 105 | service apache2 restart 106 | # stopping apache since ZTPServer will run in standalone mode on port 8080 107 | service apache2 stop 108 | update-rc.d -f apache2 remove 109 | service apache2 status 110 | 111 | ###################################### 112 | # CONFIGURE BIND 113 | ###################################### 114 | mv /etc/bind/named.conf.default-zones /etc/bind/named.conf.default-zones.bak 115 | touch /etc/bind/named.conf.default-zones 116 | cp /tmp/packer/named.conf.local /etc/bind/named.conf.local 117 | mkdir /etc/bind/zones 118 | cp /tmp/packer/db.ztps-test.com /etc/bind/zones/db.ztps-test.com 119 | 120 | service bind9 restart 121 | named-checkconf -z 122 | 123 | ###################################### 124 | # CONFIGURE DHCP 125 | ###################################### 126 | mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak 127 | cp /tmp/packer/dhcpd.conf /etc/dhcp/dhcpd.conf 128 | service isc-dhcp-server start 129 | 130 | ###################################### 131 | # INSTALL ZTPSERVER 132 | ###################################### 133 | cd /home/ztpsadmin 134 | 135 | # clone from GitHub 136 | git clone https://github.com/arista-eosplus/ztpserver.git 137 | cd ztpserver 138 | git checkout v1.4 139 | 140 | # build/install 141 | python setup.py build 142 | python setup.py install 143 | 144 | mkdir /home/ztpsadmin/ztps-sampleconfig 145 | cd /home/ztpsadmin/ztps-sampleconfig 146 | git clone https://github.com/arista-eosplus/ztpserver-demo.git 147 | 148 | cd ztpserver-demo/ 149 | cp -R ./definitions /usr/share/ztpserver/ 150 | cp -R ./files /usr/share/ztpserver/ 151 | cp -R ./nodes /usr/share/ztpserver/ 152 | cp -R ./resources /usr/share/ztpserver/ 153 | cp -R ./neighbordb /usr/share/ztpserver/ 154 | cp ztpserver.conf /etc/ztpserver/ztpserver.conf 155 | cp bootstrap.conf /usr/share/ztpserver/bootstrap/bootstrap.conf 156 | 157 | cd /usr/share/ztpserver/files 158 | mkdir images 159 | cp -R /tmp/packer/files/images . 160 | mkdir puppet 161 | cp -R /tmp/packer/files/puppet . 162 | 163 | echo "auto lo 164 | iface lo inet loopback 165 | 166 | auto eth0 167 | iface eth0 inet dhcp 168 | 169 | auto eth1 170 | iface eth1 inet static 171 | address 172.16.130.10 172 | netmask 255.255.255.0 173 | " > /etc/network/interfaces 174 | 175 | ###################################### 176 | # Prepare ZTPServer for WSGI 177 | ###################################### 178 | # modify SELinux policy 179 | chown -R www-data:www-data /usr/share/ztpserver 180 | chcon -R -h system_u:object_r:httpd_sys_script_rw_t /usr/share/ztpserver 181 | -------------------------------------------------------------------------------- /Fedora/scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | # enable delta RPM's to make yum faster 4 | yum -y install deltarpm 5 | 6 | # grab updates and cleanup 7 | yum -y update yum 8 | yum -y update 9 | 10 | # install ztps-related related packages 11 | yum -y install python-pip 12 | yum -y install mod_wsgi 13 | yum -y install tar 14 | yum -y install wget 15 | yum -y install libyaml libyaml-devel 16 | yum -y install screen 17 | yum -y install git 18 | yum -y install net-tools 19 | yum -y install tcpdump 20 | yum -y install lldpad 21 | yum -y install httpd 22 | yum -y install dhcp 23 | yum -y install bind bind-utils 24 | yum -y install ejabberd 25 | yum -y install rsyslog 26 | yum -y install ntp 27 | 28 | 29 | ###################################### 30 | # Configure tty 31 | ###################################### 32 | #enable serial console: 33 | # enable serial console 34 | systemctl start serial-getty@ttyS0.service 35 | # systemctl enable serial-getty@ttyS0.service 36 | ln -s /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service 37 | 38 | #enable boot logging to console: 39 | sed -i '/append/ s/$/ console=tty0 console=ttyS0,9600 net.ifnames=0/' /etc/extlinux.conf 40 | sed -i '/append/ s/$/ console=tty0 console=ttyS0,9600 net.ifnames=0/' /boot/extlinux/extlinux.conf 41 | 42 | #enable login on serial console 43 | echo 'ttyS0' >> /etc/securetty 44 | 45 | ###################################### 46 | # CONFIGURE FIREWALLd 47 | ###################################### 48 | # disable firewalld 49 | systemctl disable firewalld.service 50 | systemctl stop firewalld.service 51 | firewall-cmd --state 52 | ifconfig 53 | 54 | ###################################### 55 | # CONFIGURE LLDP 56 | ###################################### 57 | systemctl start lldpad 58 | systemctl enable lldpad 59 | lldptool -L -i eth1 adminStatus=rxtx 60 | lldptool -T -i eth1 -V sysName enableTx=yes 61 | lldptool -T -i eth1 -V sysDesc enableTx=yes 62 | 63 | ###################################### 64 | # CONFIGURE SCREEN 65 | ###################################### 66 | cp /tmp/packer/screenrc /home/ztpsadmin/.screenrc 67 | cp /tmp/packer/screenrc /root/.screenrc 68 | 69 | ###################################### 70 | # CONFIGURE rsyslog 71 | ###################################### 72 | mv /etc/rsyslog.conf /etc/rsyslog.conf.bak 73 | cp /tmp/packer/rsyslog.conf /etc/rsyslog.conf 74 | systemctl restart rsyslog.service 75 | netstat -tuplen | grep syslog 76 | 77 | ###################################### 78 | # CONFIGURE ntp 79 | ###################################### 80 | cp /tmp/packer/ntp.conf /etc/ntp.conf 81 | echo -e "#Generated by packer (EOS+) to limit ntp to eth1\nOPTIONS=\"-g -I eth1\"" > /etc/sysconfig/ntpd 82 | systemctl restart ntpd.service 83 | systemctl enable ntpd.service 84 | 85 | ###################################### 86 | # CONFIGURE eJabberd 87 | ###################################### 88 | mv /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberd.cfg.bak 89 | cp /tmp/packer/ejabberd.cfg /etc/ejabberd/ejabberd.cfg 90 | echo -e "127.0.0.1 ztps ztps.ztps-test.com" >> /etc/hosts 91 | ejabberdctl start 92 | sleep 2 93 | ejabberdctl status 94 | systemctl enable ejabberd.service 95 | ejabberdctl register cvx im.ztps-test.com eosplus 96 | ejabberdctl register ztpsadmin im.ztps-test.com eosplus 97 | ejabberdctl register bootstrap im.ztps-test.com eosplus 98 | ejabberdctl register veos-dc1-pod1-tor1 im.ztps-test.com eosplus 99 | ejabberdctl register veos-dc1-pod1-tor2 im.ztps-test.com eosplus 100 | ejabberdctl register veos-dc1-pod1-tor3 im.ztps-test.com eosplus 101 | ejabberdctl register veos-dc1-pod1-tor4 im.ztps-test.com eosplus 102 | ejabberdctl register veos-dc1-pod1-tor5 im.ztps-test.com eosplus 103 | ejabberdctl register veos-dc1-pod1-tor6 im.ztps-test.com eosplus 104 | ejabberdctl register veos-dc1-pod1-spine1 im.ztps-test.com eosplus 105 | ejabberdctl register veos-dc1-pod1-spine2 im.ztps-test.com eosplus 106 | ejabberdctl register veos-dc1-pod1-spine3 im.ztps-test.com eosplus 107 | ejabberdctl register veos-dc1-pod1-spine4 im.ztps-test.com eosplus 108 | ejabberdctl restart 109 | sleep 6 110 | ejabberdctl status 111 | 112 | ###################################### 113 | # CONFIGURE APACHE 114 | ###################################### 115 | mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak 116 | cp /tmp/packer/httpd.conf /etc/httpd/conf/httpd.conf 117 | 118 | ###################################### 119 | # CONFIGURE BIND 120 | ###################################### 121 | mv /etc/named.conf /etc/named.conf.bak 122 | cp /tmp/packer/named.conf /etc/named.conf 123 | cp /tmp/packer/ztps-test.com.zone /var/named/ 124 | service named restart 125 | systemctl enable named.service 126 | systemctl status named.service 127 | 128 | ###################################### 129 | # CONFIGURE DHCP 130 | ###################################### 131 | mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak 132 | cp /tmp/packer/dhcpd.conf /etc/dhcp/dhcpd.conf 133 | systemctl restart dhcpd.service 134 | systemctl enable dhcpd.service 135 | systemctl status dhcpd.service 136 | 137 | ###################################### 138 | # INSTALL ZTPSERVER 139 | ###################################### 140 | cd /home/ztpsadmin 141 | 142 | # clone from GitHub 143 | git clone https://github.com/arista-eosplus/ztpserver.git 144 | cd ztpserver 145 | git checkout v1.4 146 | 147 | # build/install 148 | python setup.py build 149 | python setup.py install 150 | 151 | mkdir /home/ztpsadmin/ztps-sampleconfig 152 | cd /home/ztpsadmin/ztps-sampleconfig 153 | git clone https://github.com/arista-eosplus/ztpserver-demo.git 154 | 155 | cd ztpserver-demo/ 156 | cp -R ./definitions /usr/share/ztpserver/ 157 | cp -R ./files /usr/share/ztpserver/ 158 | cp -R ./nodes /usr/share/ztpserver/ 159 | cp -R ./resources /usr/share/ztpserver/ 160 | cp -R ./neighbordb /usr/share/ztpserver/ 161 | cp ztpserver.conf /etc/ztpserver/ztpserver.conf 162 | cp bootstrap.conf /usr/share/ztpserver/bootstrap/bootstrap.conf 163 | 164 | 165 | cd /usr/share/ztpserver/files 166 | mkdir images 167 | cp -R /tmp/packer/files/images . 168 | mkdir puppet 169 | cp -R /tmp/packer/files/puppet . 170 | 171 | ###################################### 172 | # Prepare ZTPServer for WSGI 173 | ###################################### 174 | chown -R ztpsadmin:ztpsadmin /usr/share/ztpserver 175 | chmod -R ug+rw /usr/share/ztpserver 176 | chcon -Rv --type=httpd_sys_script_rw_t /usr/share/ztpserver 177 | -------------------------------------------------------------------------------- /Fedora/conf/prosody.cfg.lua: -------------------------------------------------------------------------------- 1 | -- Prosody Example Configuration File 2 | -- 3 | -- Information on configuring Prosody can be found on our 4 | -- website at http://prosody.im/doc/configure 5 | -- 6 | -- Tip: You can check that the syntax of this file is correct 7 | -- when you have finished by running: luac -p prosody.cfg.lua 8 | -- If there are any errors, it will let you know what and where 9 | -- they are, otherwise it will keep quiet. 10 | -- 11 | -- The only thing left to do is rename this file to remove the .dist ending, and fill in the 12 | -- blanks. Good luck, and happy Jabbering! 13 | 14 | 15 | ---------- Server-wide settings ---------- 16 | -- Settings in this section apply to the whole server and are the default settings 17 | -- for any virtual hosts 18 | 19 | -- This is a (by default, empty) list of accounts that are admins 20 | -- for the server. Note that you must create the accounts separately 21 | -- (see http://prosody.im/doc/creating_accounts for info) 22 | -- Example: admins = { "user1@example.com", "user2@example.net" } 23 | 24 | admins = { "ztpsadmin@im.ztps-test.com" } 25 | 26 | -- Enable use of libevent for better performance under high load 27 | -- For more information see: http://prosody.im/doc/libevent 28 | use_libevent = False; 29 | 30 | -- This is the list of modules Prosody will load on startup. 31 | -- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too. 32 | -- Documentation on modules can be found at: http://prosody.im/doc/modules 33 | modules_enabled = { 34 | 35 | -- Generally required 36 | "roster"; -- Allow users to have a roster. Recommended ;) 37 | "saslauth"; -- Authentication for clients and servers. Recommended if you want to log in. 38 | --"tls"; -- Add support for secure TLS on c2s/s2s connections 39 | "dialback"; -- s2s dialback support 40 | "disco"; -- Service discovery 41 | 42 | -- Not essential, but recommended 43 | "private"; -- Private XML storage (for room bookmarks, etc.) 44 | "vcard"; -- Allow users to set vCards 45 | 46 | -- These are commented by default as they have a performance impact 47 | --"privacy"; -- Support privacy lists 48 | --"compression"; -- Stream compression 49 | 50 | -- Nice to have 51 | "version"; -- Replies to server version requests 52 | "uptime"; -- Report how long server has been running 53 | "time"; -- Let others know the time here on this server 54 | "ping"; -- Replies to XMPP pings with pongs 55 | "pep"; -- Enables users to publish their mood, activity, playing music and more 56 | "register"; -- Allow users to register on this server using a client and change passwords 57 | 58 | -- Admin interfaces 59 | "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands 60 | --"admin_telnet"; -- Opens telnet console interface on localhost port 5582 61 | 62 | -- HTTP modules 63 | --"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP" 64 | "http_files"; -- Serve static files from a directory over HTTP 65 | 66 | -- Other specific functionality 67 | "posix"; -- POSIX functionality, sends server to background, enables syslog, etc. 68 | --"groups"; -- Shared roster support 69 | --"announce"; -- Send announcement to all online users 70 | --"welcome"; -- Welcome users who register accounts 71 | --"watchregistrations"; -- Alert admins of registrations 72 | --"motd"; -- Send a message to users when they log in 73 | --"legacyauth"; -- Legacy authentication. Only used by some old clients and bots. 74 | }; 75 | 76 | -- These modules are auto-loaded, but should you want 77 | -- to disable them then uncomment them here: 78 | modules_disabled = { 79 | -- "offline"; -- Store offline messages 80 | -- "c2s"; -- Handle client connections 81 | "s2s"; -- Handle server-to-server connections 82 | }; 83 | 84 | -- Disable account creation by default, for security 85 | -- For more information see http://prosody.im/doc/creating_accounts 86 | allow_registration = false; 87 | 88 | -- These are the SSL/TLS-related settings. If you don't want 89 | -- to use SSL/TLS, you may comment or remove this 90 | -- ssl = { 91 | -- key = "/etc/pki/tls/private/prosody.key"; 92 | -- certificate = "/etc/pki/tls/certs/prosody.crt"; 93 | -- } 94 | 95 | -- Force clients to use encrypted connections? This option will 96 | -- prevent clients from authenticating unless they are using encryption. 97 | 98 | c2s_require_encryption = false 99 | 100 | -- Force certificate authentication for server-to-server connections? 101 | -- This provides ideal security, but requires servers you communicate 102 | -- with to support encryption AND present valid, trusted certificates. 103 | -- NOTE: Your version of LuaSec must support certificate verification! 104 | -- For more information see http://prosody.im/doc/s2s#security 105 | 106 | s2s_secure_auth = false 107 | 108 | -- Many servers don't support encryption or have invalid or self-signed 109 | -- certificates. You can list domains here that will not be required to 110 | -- authenticate using certificates. They will be authenticated using DNS. 111 | 112 | --s2s_insecure_domains = { "gmail.com" } 113 | 114 | -- Even if you leave s2s_secure_auth disabled, you can still require valid 115 | -- certificates for some domains by specifying a list here. 116 | 117 | --s2s_secure_domains = { "jabber.org" } 118 | 119 | -- Select the authentication backend to use. The 'internal' providers 120 | -- use Prosody's configured data storage to store the authentication data. 121 | -- To allow Prosody to offer secure authentication mechanisms to clients, the 122 | -- default provider stores passwords in plaintext. If you do not trust your 123 | -- server please see http://prosody.im/doc/modules/mod_auth_internal_hashed 124 | -- for information about using the hashed backend. 125 | 126 | authentication = "internal_plain" 127 | 128 | -- Select the storage backend to use. By default Prosody uses flat files 129 | -- in its configured data directory, but it also supports more backends 130 | -- through modules. An "sql" backend is included by default, but requires 131 | -- additional dependencies. See http://prosody.im/doc/storage for more info. 132 | 133 | --storage = "sql" -- Default is "internal" 134 | 135 | -- For the "sql" backend, you can uncomment *one* of the below to configure: 136 | --sql = { driver = "SQLite3", database = "prosody.sqlite" } -- Default. 'database' is the filename. 137 | --sql = { driver = "MySQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } 138 | -- sql = { driver = "PostgreSQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } 139 | 140 | -- Logging configuration 141 | -- For advanced logging see http://prosody.im/doc/logging 142 | log = { 143 | info = "prosody.log"; -- Change 'info' to 'debug' for verbose logging 144 | error = "prosody.err"; 145 | "*syslog"; -- Uncomment this for logging to syslog 146 | -- "*console"; -- Log to the console, useful for debugging with daemonize=false 147 | } 148 | pidfile = "/var/run/prosody/prosody.pid"; 149 | 150 | ----------- Virtual hosts ----------- 151 | -- You need to add a VirtualHost entry for each domain you wish Prosody to serve. 152 | -- Settings under each VirtualHost entry apply *only* to that host. 153 | 154 | VirtualHost "localhost" 155 | 156 | VirtualHost "im.ztps-test.com" 157 | enabled = True 158 | -- Assign this host a certificate for TLS, otherwise it would use the one 159 | -- set in the global section (if any). 160 | -- Note that old-style SSL on port 5223 only supports one certificate, and will always 161 | -- use the global one. 162 | 163 | ------ Components ------ 164 | -- You can specify components to add hosts that provide special services, 165 | -- like multi-user conferences, and transports. 166 | -- For more information on components, see http://prosody.im/doc/components 167 | 168 | ---Set up a MUC (multi-user chat) room server on conference.example.com: 169 | Component "conference.im.ztps-test.com" "muc" 170 | 171 | -- Set up a SOCKS5 bytestream proxy for server-proxied file transfers: 172 | --Component "proxy.example.com" "proxy65" 173 | 174 | ---Set up an external component (default component port is 5347) 175 | -- 176 | -- External components allow adding various services, such as gateways/ 177 | -- transports to other networks like ICQ, MSN and Yahoo. For more info 178 | -- see: http://prosody.im/doc/components#adding_an_external_component 179 | -- 180 | --Component "gateway.example.com" 181 | -- component_secret = "password" 182 | -------------------------------------------------------------------------------- /Ubuntu/conf/prosody.cfg.lua: -------------------------------------------------------------------------------- 1 | -- Prosody Example Configuration File 2 | -- 3 | -- Information on configuring Prosody can be found on our 4 | -- website at http://prosody.im/doc/configure 5 | -- 6 | -- Tip: You can check that the syntax of this file is correct 7 | -- when you have finished by running: luac -p prosody.cfg.lua 8 | -- If there are any errors, it will let you know what and where 9 | -- they are, otherwise it will keep quiet. 10 | -- 11 | -- The only thing left to do is rename this file to remove the .dist ending, and fill in the 12 | -- blanks. Good luck, and happy Jabbering! 13 | 14 | 15 | ---------- Server-wide settings ---------- 16 | -- Settings in this section apply to the whole server and are the default settings 17 | -- for any virtual hosts 18 | 19 | -- This is a (by default, empty) list of accounts that are admins 20 | -- for the server. Note that you must create the accounts separately 21 | -- (see http://prosody.im/doc/creating_accounts for info) 22 | -- Example: admins = { "user1@example.com", "user2@example.net" } 23 | 24 | admins = { "ztpsadmin@im.ztps-test.com" } 25 | 26 | -- Enable use of libevent for better performance under high load 27 | -- For more information see: http://prosody.im/doc/libevent 28 | use_libevent = False; 29 | 30 | -- This is the list of modules Prosody will load on startup. 31 | -- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too. 32 | -- Documentation on modules can be found at: http://prosody.im/doc/modules 33 | modules_enabled = { 34 | 35 | -- Generally required 36 | "roster"; -- Allow users to have a roster. Recommended ;) 37 | "saslauth"; -- Authentication for clients and servers. Recommended if you want to log in. 38 | --"tls"; -- Add support for secure TLS on c2s/s2s connections 39 | "dialback"; -- s2s dialback support 40 | "disco"; -- Service discovery 41 | 42 | -- Not essential, but recommended 43 | "private"; -- Private XML storage (for room bookmarks, etc.) 44 | "vcard"; -- Allow users to set vCards 45 | 46 | -- These are commented by default as they have a performance impact 47 | --"privacy"; -- Support privacy lists 48 | --"compression"; -- Stream compression 49 | 50 | -- Nice to have 51 | "version"; -- Replies to server version requests 52 | "uptime"; -- Report how long server has been running 53 | "time"; -- Let others know the time here on this server 54 | "ping"; -- Replies to XMPP pings with pongs 55 | "pep"; -- Enables users to publish their mood, activity, playing music and more 56 | "register"; -- Allow users to register on this server using a client and change passwords 57 | 58 | -- Admin interfaces 59 | "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands 60 | --"admin_telnet"; -- Opens telnet console interface on localhost port 5582 61 | 62 | -- HTTP modules 63 | --"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP" 64 | "http_files"; -- Serve static files from a directory over HTTP 65 | 66 | -- Other specific functionality 67 | "posix"; -- POSIX functionality, sends server to background, enables syslog, etc. 68 | --"groups"; -- Shared roster support 69 | --"announce"; -- Send announcement to all online users 70 | --"welcome"; -- Welcome users who register accounts 71 | --"watchregistrations"; -- Alert admins of registrations 72 | --"motd"; -- Send a message to users when they log in 73 | --"legacyauth"; -- Legacy authentication. Only used by some old clients and bots. 74 | }; 75 | 76 | -- These modules are auto-loaded, but should you want 77 | -- to disable them then uncomment them here: 78 | modules_disabled = { 79 | -- "offline"; -- Store offline messages 80 | -- "c2s"; -- Handle client connections 81 | "s2s"; -- Handle server-to-server connections 82 | }; 83 | 84 | -- Disable account creation by default, for security 85 | -- For more information see http://prosody.im/doc/creating_accounts 86 | allow_registration = false; 87 | 88 | -- These are the SSL/TLS-related settings. If you don't want 89 | -- to use SSL/TLS, you may comment or remove this 90 | -- ssl = { 91 | -- key = "/etc/pki/tls/private/prosody.key"; 92 | -- certificate = "/etc/pki/tls/certs/prosody.crt"; 93 | -- } 94 | 95 | -- Force clients to use encrypted connections? This option will 96 | -- prevent clients from authenticating unless they are using encryption. 97 | 98 | c2s_require_encryption = false 99 | 100 | -- Force certificate authentication for server-to-server connections? 101 | -- This provides ideal security, but requires servers you communicate 102 | -- with to support encryption AND present valid, trusted certificates. 103 | -- NOTE: Your version of LuaSec must support certificate verification! 104 | -- For more information see http://prosody.im/doc/s2s#security 105 | 106 | s2s_secure_auth = false 107 | 108 | -- Many servers don't support encryption or have invalid or self-signed 109 | -- certificates. You can list domains here that will not be required to 110 | -- authenticate using certificates. They will be authenticated using DNS. 111 | 112 | --s2s_insecure_domains = { "gmail.com" } 113 | 114 | -- Even if you leave s2s_secure_auth disabled, you can still require valid 115 | -- certificates for some domains by specifying a list here. 116 | 117 | --s2s_secure_domains = { "jabber.org" } 118 | 119 | -- Select the authentication backend to use. The 'internal' providers 120 | -- use Prosody's configured data storage to store the authentication data. 121 | -- To allow Prosody to offer secure authentication mechanisms to clients, the 122 | -- default provider stores passwords in plaintext. If you do not trust your 123 | -- server please see http://prosody.im/doc/modules/mod_auth_internal_hashed 124 | -- for information about using the hashed backend. 125 | 126 | authentication = "internal_plain" 127 | 128 | -- Select the storage backend to use. By default Prosody uses flat files 129 | -- in its configured data directory, but it also supports more backends 130 | -- through modules. An "sql" backend is included by default, but requires 131 | -- additional dependencies. See http://prosody.im/doc/storage for more info. 132 | 133 | --storage = "sql" -- Default is "internal" 134 | 135 | -- For the "sql" backend, you can uncomment *one* of the below to configure: 136 | --sql = { driver = "SQLite3", database = "prosody.sqlite" } -- Default. 'database' is the filename. 137 | --sql = { driver = "MySQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } 138 | -- sql = { driver = "PostgreSQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } 139 | 140 | -- Logging configuration 141 | -- For advanced logging see http://prosody.im/doc/logging 142 | log = { 143 | info = "prosody.log"; -- Change 'info' to 'debug' for verbose logging 144 | error = "prosody.err"; 145 | "*syslog"; -- Uncomment this for logging to syslog 146 | -- "*console"; -- Log to the console, useful for debugging with daemonize=false 147 | } 148 | pidfile = "/var/run/prosody/prosody.pid"; 149 | 150 | ----------- Virtual hosts ----------- 151 | -- You need to add a VirtualHost entry for each domain you wish Prosody to serve. 152 | -- Settings under each VirtualHost entry apply *only* to that host. 153 | 154 | VirtualHost "localhost" 155 | 156 | VirtualHost "im.ztps-test.com" 157 | enabled = True 158 | -- Assign this host a certificate for TLS, otherwise it would use the one 159 | -- set in the global section (if any). 160 | -- Note that old-style SSL on port 5223 only supports one certificate, and will always 161 | -- use the global one. 162 | 163 | ------ Components ------ 164 | -- You can specify components to add hosts that provide special services, 165 | -- like multi-user conferences, and transports. 166 | -- For more information on components, see http://prosody.im/doc/components 167 | 168 | ---Set up a MUC (multi-user chat) room server on conference.example.com: 169 | Component "conference.im.ztps-test.com" "muc" 170 | 171 | -- Set up a SOCKS5 bytestream proxy for server-proxied file transfers: 172 | --Component "proxy.example.com" "proxy65" 173 | 174 | ---Set up an external component (default component port is 5347) 175 | -- 176 | -- External components allow adding various services, such as gateways/ 177 | -- transports to other networks like ICQ, MSN and Yahoo. For more info 178 | -- see: http://prosody.im/doc/components#adding_an_external_component 179 | -- 180 | --Component "gateway.example.com" 181 | -- component_secret = "password" 182 | -------------------------------------------------------------------------------- /Fedora/scripts/setup-32b.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | #enable delta rpms's to make yum faster 4 | yum -y install deltarpm 5 | 6 | #Grab updates and cleanup 7 | yum -y update yum 8 | yum -y update 9 | 10 | #Install ztps-related related packages 11 | #yum -y install python-devel 12 | yum -y install python-pip 13 | yum -y install mod_wsgi 14 | #yum -y install gcc make gcc-c++ 15 | yum -y install tar 16 | yum -y install wget 17 | yum -y install libyaml libyaml-devel 18 | yum -y install screen 19 | yum -y install git 20 | yum -y install net-tools 21 | yum -y install tcpdump 22 | yum -y install lldpad 23 | yum -y install httpd 24 | yum -y install dhcp 25 | yum -y install bind bind-utils 26 | #yum -y install ejabberd 27 | yum -y install rsyslog 28 | yum -y install ntp 29 | yum -y install prosody 30 | 31 | 32 | ###################################### 33 | # Configure tty 34 | ###################################### 35 | #enable serial console: 36 | # enable serial console 37 | systemctl start serial-getty@ttyS0.service 38 | # systemctl enable serial-getty@ttyS0.service 39 | ln -s /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service 40 | 41 | #enable boot logging to console: 42 | sed -i '/append/ s/$/ console=tty0 console=ttyS0,9600 net.ifnames=0/' /etc/extlinux.conf 43 | sed -i '/append/ s/$/ console=tty0 console=ttyS0,9600 net.ifnames=0/' /boot/extlinux/extlinux.conf 44 | 45 | #enable login on serial console 46 | echo 'ttyS0' >> /etc/securetty 47 | 48 | ###################################### 49 | # CONFIGURE FIREWALLd 50 | ###################################### 51 | #Disable firewalld 52 | systemctl disable firewalld.service 53 | systemctl stop firewalld.service 54 | firewall-cmd --state 55 | ifconfig 56 | 57 | ###################################### 58 | # CONFIGURE LLDP 59 | ###################################### 60 | systemctl start lldpad 61 | systemctl enable lldpad 62 | lldptool -L -i eth1 adminStatus=rxtx 63 | lldptool -T -i eth1 -V sysName enableTx=yes 64 | lldptool -T -i eth1 -V sysDesc enableTx=yes 65 | 66 | ###################################### 67 | # CONFIGURE SCREEN 68 | ###################################### 69 | cp /tmp/packer/screenrc /home/ztpsadmin/.screenrc 70 | cp /tmp/packer/screenrc /root/.screenrc 71 | 72 | ###################################### 73 | # CONFIGURE rsyslog 74 | ###################################### 75 | mv /etc/rsyslog.conf /etc/rsyslog.conf.bak 76 | cp /tmp/packer/rsyslog.conf /etc/rsyslog.conf 77 | systemctl restart rsyslog.service 78 | netstat -tuplen | grep syslog 79 | 80 | ###################################### 81 | # CONFIGURE ntp 82 | ###################################### 83 | cp /tmp/packer/ntp.conf /etc/ntp.conf 84 | echo -e "#Generated by packer (EOS+) to limit ntp to eth1\nOPTIONS=\"-g -I eth1\"" > /etc/sysconfig/ntpd 85 | # systemctl restart ntpd.service 86 | # systemctl enable ntpd.service 87 | # systemctl stop ntpd.service 88 | 89 | ###################################### 90 | # CONFIGURE eJabberd 91 | ###################################### 92 | #mv /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberd.cfg.bak 93 | #cp /tmp/packer/ejabberd.cfg /etc/ejabberd/ejabberd.cfg 94 | #echo -e "127.0.0.1 ztps ztps.ztps-test.com" >> /etc/hosts 95 | #ejabberdctl start 96 | #sleep 2 97 | #ejabberdctl status 98 | #systemctl enable ejabberd.service 99 | #ejabberdctl register cvx im.ztps-test.com eosplus 100 | #ejabberdctl register ztpsadmin im.ztps-test.com eosplus 101 | #ejabberdctl register bootstrap im.ztps-test.com eosplus 102 | #ejabberdctl register veos-dc1-pod1-tor1 im.ztps-test.com eosplus 103 | #ejabberdctl register veos-dc1-pod1-tor2 im.ztps-test.com eosplus 104 | #ejabberdctl register veos-dc1-pod1-tor3 im.ztps-test.com eosplus 105 | #ejabberdctl register veos-dc1-pod1-tor4 im.ztps-test.com eosplus 106 | #ejabberdctl register veos-dc1-pod1-tor5 im.ztps-test.com eosplus 107 | #ejabberdctl register veos-dc1-pod1-tor6 im.ztps-test.com eosplus 108 | #ejabberdctl register veos-dc1-pod1-spine1 im.ztps-test.com eosplus 109 | #ejabberdctl register veos-dc1-pod1-spine2 im.ztps-test.com eosplus 110 | #ejabberdctl register veos-dc1-pod1-spine3 im.ztps-test.com eosplus 111 | #ejabberdctl register veos-dc1-pod1-spine4 im.ztps-test.com eosplus 112 | #ejabberdctl restart 113 | #sleep 6 114 | #ejabberdctl status 115 | 116 | ###################################### 117 | # CONFIGURE Prosody for XMPP 118 | ###################################### 119 | mv /etc/prosody/prosody.cfg.lua /etc/prosody/prosody.cfg.lua.bak 120 | cp /tmp/packer/prosody.cfg.lua /etc/prosody/prosody.cfg.lua 121 | echo -e "127.0.0.1 ztps im.ztps-test.com" >> /etc/hosts 122 | prosodyctl start 123 | systemctl enable prosody 124 | prosodyctl register cvx im.ztps-test.com eosplus 125 | prosodyctl register ztpsadmin im.ztps-test.com eosplus 126 | prosodyctl register bootstrap im.ztps-test.com eosplus 127 | prosodyctl register veos-dc1-pod1-tor1 im.ztps-test.com eosplus 128 | prosodyctl register veos-dc1-pod1-tor2 im.ztps-test.com eosplus 129 | prosodyctl register veos-dc1-pod1-tor3 im.ztps-test.com eosplus 130 | prosodyctl register veos-dc1-pod1-tor4 im.ztps-test.com eosplus 131 | prosodyctl register veos-dc1-pod1-tor5 im.ztps-test.com eosplus 132 | prosodyctl register veos-dc1-pod1-tor6 im.ztps-test.com eosplus 133 | prosodyctl register veos-dc1-pod1-spine1 im.ztps-test.com eosplus 134 | prosodyctl register veos-dc1-pod1-spine2 im.ztps-test.com eosplus 135 | prosodyctl register veos-dc1-pod1-spine3 im.ztps-test.com eosplus 136 | prosodyctl register veos-dc1-pod1-spine4 im.ztps-test.com eosplus 137 | prosodyctl restart 138 | sleep 6 139 | prosodyctl status 140 | 141 | 142 | ###################################### 143 | # CONFIGURE APACHE 144 | ###################################### 145 | mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak 146 | cp /tmp/packer/httpd.conf /etc/httpd/conf/httpd.conf 147 | # systemctl restart httpd.service 148 | # Stopping httpd since ztps will manage this 149 | # systemctl stop httpd.service 150 | 151 | ###################################### 152 | # CONFIGURE BIND 153 | ###################################### 154 | mv /etc/named.conf /etc/named.conf.bak 155 | cp /tmp/packer/named.conf /etc/named.conf 156 | cp /tmp/packer/ztps-test.com.zone /var/named/ 157 | # service named restart 158 | systemctl stop named.service 159 | systemctl disable named.service 160 | 161 | ###################################### 162 | # CONFIGURE DHCP 163 | ###################################### 164 | mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak 165 | cp /tmp/packer/dhcpd.conf /etc/dhcp/dhcpd.conf 166 | # systemctl restart dhcpd.service 167 | systemctl stop dhcpd.service 168 | systemctl disable dhcpd.service 169 | 170 | ###################################### 171 | # INSTALL ZTPSERVER 172 | ###################################### 173 | #mkdir /etc 174 | cd /home/ztpsadmin 175 | 176 | #clone from GitHub 177 | git clone https://github.com/arista-eosplus/ztpserver.git -b develop 178 | cd ztpserver 179 | git checkout v1.4 180 | 181 | #build/install 182 | python setup.py build 183 | python setup.py install 184 | 185 | mkdir /home/ztpsadmin/ztps-sampleconfig 186 | cd /home/ztpsadmin/ztps-sampleconfig 187 | git clone https://github.com/arista-eosplus/ztpserver-demo.git 188 | 189 | cd ztpserver-demo/ 190 | cp -R ./definitions /usr/share/ztpserver/ 191 | cp -R ./files /usr/share/ztpserver/ 192 | cp -R ./nodes /usr/share/ztpserver/ 193 | cp -R ./resources /usr/share/ztpserver/ 194 | cp -R ./neighbordb /usr/share/ztpserver/ 195 | cp ztpserver-eos.conf /etc/ztpserver/ztpserver.conf 196 | cp bootstrap.conf /usr/share/ztpserver/bootstrap/bootstrap.conf 197 | 198 | 199 | cd /usr/share/ztpserver/files 200 | mkdir images 201 | cp -R /tmp/packer/files/images . 202 | mkdir puppet 203 | cp -R /tmp/packer/files/puppet . 204 | 205 | # Set eth0 IP 206 | MAC=$(ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}') 207 | cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak 208 | 209 | echo "DEVICE=eth0 210 | BOOTPROTO=none 211 | ONBOOT=yes 212 | TYPE=Ethernet 213 | IPADDR=10.0.0.2 214 | PREFIX=24 215 | GATEWAY=10.0.0.1 216 | DEFROUTE=yes 217 | IPV6INIT=no 218 | NAME='System eth0' 219 | HWADDR=${MAC} 220 | " > /etc/sysconfig/network-scripts/ifcfg-eth0 221 | 222 | hostnamectl set-hostname ztps 223 | 224 | ###################################### 225 | # Prepare ZTPServer for WSGI 226 | ###################################### 227 | chown -R ztpsadmin:ztpsadmin /usr/share/ztpserver 228 | chmod -R ug+rw /usr/share/ztpserver 229 | chcon -Rv --type=httpd_sys_script_rw_t /usr/share/ztpserver 230 | 231 | 232 | ####Cleanup 233 | yum remove -y fedora-logos 234 | #yum remove -y kernel-3.11.10-301.fc20.x86_64 235 | yum remove -y poppler-data 236 | yum remove -y atk 237 | cd /usr/share/doc/ && rm -rf ./* 238 | yum clean all 239 | -------------------------------------------------------------------------------- /create-ztpserver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | #################################### 4 | # Automatically setup a ZTPServer VM 5 | # Author: eosplus-dev@arista.com 6 | # Date: 20150113 7 | #################################### 8 | 9 | import sys 10 | import os 11 | newPath = os.path.join(os.getcwd(), "lib") 12 | sys.path.append(newPath) 13 | from eosplusvnets import * 14 | 15 | 16 | def createVM(hyper, hostOS, vmOS, vmName, vmSize, user, packerCmd, **kwargs): 17 | 18 | d = datetime.datetime.now() 19 | time = d.strftime("%Y%m%d_%H%M%S") 20 | 21 | # Set packer logging variable 22 | os.environ['PACKER_LOG'] = "enable" 23 | os.environ['PACKER_LOG_PATH'] = "./packer-debug.log" 24 | 25 | if vmName: 26 | vmName = "%s-%s_%s" % (vmName, vmOS, time) 27 | else: 28 | vmName = "ztps-%s_%s" % (vmOS, time) 29 | 30 | print "Using VM name %s" % vmName 31 | print "Creating VM with user %s" % user 32 | 33 | print bcolors.WARNING 34 | print "##############################################" 35 | print "WARNING: DO NOT TYPE IN VIRTUAL MACHINE WINDOW" 36 | print "##############################################" 37 | print bcolors.ENDC 38 | 39 | if (hostOS == "windows" and hyper == "virtualbox"): 40 | build = "--only=%s-windows-iso" % hyper 41 | elif vmOS == "eos": 42 | build = "--only=%s-iso-eos" % hyper 43 | else: 44 | build = "--only=%s-iso" % hyper 45 | 46 | nameVar = "name=%s" % vmName 47 | 48 | try: 49 | opts = "-var name='%s' -var disk-size=%s" % (vmName, vmSize) 50 | 51 | if vmOS == "fedora": 52 | wkd = os.path.join(os.getcwd(), "Fedora") 53 | builder_file = "ztps-fedora_20_x86_64.json" 54 | if hyper == "esxi": 55 | esxi = kwargs["esxi_info"] 56 | opts += (" -var esxi-user='%s' -var esxi-passwd='%s' " 57 | "-var esxi-host='%s' -var esxi-path='%s' " 58 | "-var esxi-network='%s'") % (esxi['user'], 59 | esxi['passwd'], 60 | esxi['host'], 61 | esxi['datastore'], 62 | esxi['network']) 63 | elif vmOS == "eos": 64 | wkd = os.path.join(os.getcwd(), "Fedora") 65 | builder_file = "ztps-fedora_20_i386.json" 66 | if hyper == "esxi": 67 | esxi = kwargs["esxi_info"] 68 | opts += (" -var esxi-user='%s' -var esxi-passwd='%s' " 69 | "-var esxi-host='%s' -var esxi-path='%s' " 70 | "-var esxi-network='%s'") % (esxi['user'], 71 | esxi['passwd'], 72 | esxi['host'], 73 | esxi['datastore'], 74 | esxi['network']) 75 | elif vmOS == "ubuntu": 76 | wkd = os.path.join(os.getcwd(), "Ubuntu") 77 | builder_file = "ztps-ubuntu-12.04.4_amd64.json" 78 | if hyper == "esxi": 79 | esxi = kwargs["esxi_info"] 80 | opts += (" -var esxi-user='%s' -var esxi-passwd='%s' " 81 | "-var esxi-host='%s' -var esxi-path='%s' " 82 | "-var esxi-network='%s'") % (esxi['user'], 83 | esxi['passwd'], 84 | esxi['host'], 85 | esxi['datastore'], 86 | esxi['network']) 87 | 88 | build_cmd = "%s build %s %s %s" % (packerCmd, build, opts, builder_file) 89 | print build_cmd 90 | 91 | rc = subprocess.call(build_cmd, shell=True, cwd=wkd) 92 | 93 | print "Return code:%s" % rc 94 | except OSError as e: 95 | if e.errno == os.errno.ENOENT: 96 | print "Unable to create Virtual Machine" 97 | raise 98 | else: 99 | print "Something else went wrong" 100 | raise 101 | 102 | if rc == 0: 103 | return vmName 104 | elif rc > 0: 105 | print "Packer install failed!!!" 106 | print "Please copy error ouput and raise an issue at https://github.com/arista-eosplus/packer-ztpserver/issues with your console output." 107 | exit(rc) 108 | 109 | 110 | def registerVbox(hyper, libDir, vmName, vmOS): 111 | #Import the VM into Vbox 112 | if hyper == "virtualbox": 113 | cmd = "%s/vboxmanage" % libDir 114 | vmPath = "%s-vbox/%s.ovf" % (vmName, vmName) 115 | if (vmOS == "fedora" or vmOS == "eos"): 116 | path = "Fedora/" 117 | else: 118 | path = "Ubuntu/" 119 | 120 | print "Path: %s" % path 121 | print "VM: %s" % vmPath 122 | 123 | subprocess.call([cmd, "import", "--options", "keepallmacs", vmPath], cwd=path) 124 | 125 | return True 126 | 127 | 128 | def main(): 129 | 130 | # Argument Variables 131 | hypervisors = ["vmware", "esxi", "virtualbox"] 132 | oses = ["fedora", "ubuntu", "eos"] 133 | 134 | parser = argparse.ArgumentParser(description="Automatically install the ZTPServer Demo") 135 | parser.add_argument("-H", "--hypervisor", required=True, choices=hypervisors, help="Hypervisor to create VM in") 136 | parser.add_argument("-o", "--os", required=True, choices=oses, help="Desired OS to use for VM") 137 | parser.add_argument("-n", "--vmname", help="The Virtual Machine name") 138 | parser.add_argument("-d", "--disk-size", help="VM Disk size in MB", default=7000) 139 | parser.add_argument("-u", "--esxi-user", help="The ESXi username") 140 | parser.add_argument("-e", "--esxi-host", help="The IP or hostname of the ESXi host") 141 | parser.add_argument("-p", "--datastore-path", help="The ESXi path to save the VM") 142 | parser.add_argument("-i", "--esxi-network", help="vSphere network assigned to VM \ 143 | that allows communication with local \ 144 | builder") 145 | args = parser.parse_args() 146 | 147 | # Set install variables 148 | user = getpass.getuser() 149 | if user == "root" and os.getenv("SUDO_USER") != "root": 150 | print bcolors.FAIL, "ERROR: DO NOT RUN THIS SCRIPT WITH SUDO", bcolors.ENDC 151 | exit() 152 | 153 | hyper = args.hypervisor 154 | vmOS = args.os 155 | if args.vmname: 156 | vmName = args.vmname 157 | else: 158 | vmName = "" 159 | 160 | vmSize = args.disk_size 161 | if vmSize < 3000: 162 | parser.error('3000 MB is minimum disk size for VM') 163 | 164 | if vmOS == "eos": 165 | vmSize = 4000 166 | print "Changing disk size to 4000MB for eos" 167 | 168 | if hyper == "esxi": 169 | if not args.esxi_user or not args.esxi_host or not args.esxi_network or not args.datastore_path: 170 | parser.error('esxi-host, datastore-path and esxi-network are all \ 171 | required when using the esxi hypervisor') 172 | try: 173 | print "Parsing arguments for ESXi installation:" 174 | print " - Host:%s\n - Datastore Path:%s\n - VM Network:%s" % (args.esxi_host, args.datastore_path, args.esxi_network) 175 | esxi = dict() 176 | esxi["passwd"] = getpass.getpass("Enter ESXi host password:") 177 | esxi["user"] = args.esxi_user 178 | esxi["host"] = args.esxi_host 179 | esxi["datastore"] = args.datastore_path 180 | esxi["network"] = args.esxi_network 181 | except: 182 | raise Exception("Unable to get ESXi password from user") 183 | 184 | # Get host machine information 185 | hostOS = getHostOS() 186 | hostArch = getHostArch() 187 | print "Tailoring install for a %s bit %s environment" % (hostArch, hostOS) 188 | 189 | print "Looking for hypervisor libraries" 190 | if hyper == "vmware": 191 | if hostOS == "darwin": 192 | libDir = find("/Applications", "vmnet-cli") 193 | elif hostOS == "windows": 194 | libDir = find("C:\\", "vmware.exe") 195 | elif hyper == "virtualbox": 196 | if hostOS == "darwin": 197 | libDir = find("/usr", "VBoxManage") 198 | elif hostOS == "windows": 199 | libDir = find("C:\\", "VBoxManage.exe") 200 | 201 | # Test to see if Packer is installed 202 | packerCmd = which("packer") 203 | if not packerCmd: 204 | print "Packer not found - install it" 205 | packerCmd = installPacker(hostOS, hostArch) 206 | 207 | # Setup Virtual Networks 208 | if hyper == "virtualbox": 209 | if createVBoxNets(hostOS, hostArch, libDir): 210 | # Create the Virtual Machine 211 | vmName = createVM(hyper, hostOS, vmOS, vmName, vmSize, user, 212 | packerCmd) 213 | if vmName: 214 | if registerVbox(hyper, libDir, vmName, vmOS): 215 | print "Successfully created VM %s!" % vmName 216 | exit(0) 217 | 218 | elif hyper == "vmware": 219 | if createVmNets(hostOS, hostArch, libDir): 220 | # Create the Virtual Machine 221 | vmName = createVM(hyper, hostOS, vmOS, vmName, vmSize, 222 | user, packerCmd) 223 | if vmName: 224 | print "Successfully created VM %s!" % vmName 225 | exit(0) 226 | 227 | elif hyper == "esxi": 228 | vmName = createVM(hyper, hostOS, vmOS, vmName, vmSize, user, packerCmd, 229 | esxi_info=esxi) 230 | if vmName: 231 | print "Successfully created VM %s!" % vmName 232 | exit(0) 233 | 234 | if __name__ == "__main__": 235 | try: 236 | main() 237 | except KeyboardInterrupt: 238 | print "Exiting script..." 239 | -------------------------------------------------------------------------------- /Fedora/ztps-fedora_20_x86_64.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "ram": "2048", 4 | "disk-size": "7000", 5 | "name": "ztps-fedora-20-x86_64", 6 | "esxi-user": "", 7 | "esxi-passwd": "", 8 | "esxi-host": "", 9 | "esxi-path": "", 10 | "esxi-network": "" 11 | }, 12 | "builders": [ 13 | { 14 | "boot_command": [ 15 | "", 16 | "", 17 | "vmlinuz ", 18 | "initrd=initrd.img ", 19 | "biosdevname=0 net.ifnames=0 ", 20 | "inst.stage2=hd:LABEL=Fedora\\x2020\\x20x86_64 ", 21 | "rd.live.check ", 22 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-net.cfg", 23 | "" 24 | ], 25 | "boot_wait": "10s", 26 | "disk_size": "{{user `disk-size`}}", 27 | "output_directory":"{{user `name`}}-vmware", 28 | "type": "vmware-iso", 29 | "headless":"False", 30 | "iso_checksum": "376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f", 31 | "iso_checksum_type": "sha256", 32 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-netinst.iso", 33 | "ssh_username": "root", 34 | "ssh_password":"eosplus", 35 | "ssh_port":"22", 36 | "ssh_wait_timeout": "20m", 37 | "guest_os_type": "fedora-64", 38 | "vm_name":"{{user `name`}}", 39 | "vmx_data": { 40 | "memsize": "{{user `ram`}}", 41 | "numvcpus": "1", 42 | "cpuid.coresPerSocket": "1", 43 | "ethernet0.present" : "TRUE", 44 | "ethernet0.virtualdev" : "e1000", 45 | "ethernet0.connectionType" : "nat", 46 | "ethernet0.startConnected" : "TRUE", 47 | "ethernet0.pcislotnumber" : "32", 48 | "ethernet1.pcislotnumber" : "33", 49 | "ethernet1.virtualdev" : "e1000", 50 | "ethernet1.present" : "TRUE", 51 | "ethernet1.startConnected" : "TRUE", 52 | "ethernet1.connectionType" : "custom", 53 | "ethernet1.vnet" : "vmnet2" 54 | }, 55 | "shutdown_command": "/sbin/shutdown -h now", 56 | "http_directory":"http/" 57 | }, 58 | { 59 | "boot_command": [ 60 | "", 61 | "", 62 | "vmlinuz ", 63 | "initrd=initrd.img ", 64 | "biosdevname=0 net.ifnames=0 ", 65 | "inst.stage2=hd:LABEL=Fedora\\x2020\\x20x86_64 ", 66 | "rd.live.check ", 67 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-net.cfg", 68 | "" 69 | ], 70 | "boot_wait": "10s", 71 | "disk_size": "{{user `disk-size`}}", 72 | "disk_type_id": "thin", 73 | "output_directory":"{{user `name`}}-vmware", 74 | "type": "vmware-iso", 75 | "name": "esxi-iso", 76 | "headless":"False", 77 | "iso_checksum": "376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f", 78 | "iso_checksum_type": "sha256", 79 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-netinst.iso", 80 | "ssh_username": "root", 81 | "ssh_password":"eosplus", 82 | "ssh_port":"22", 83 | "ssh_wait_timeout": "20m", 84 | "guest_os_type": "otherlinux-64", 85 | "vm_name":"{{user `name`}}", 86 | "remote_host":"{{user `esxi-host`}}", 87 | "remote_datastore":"{{user `esxi-path`}}", 88 | "remote_type":"esx5", 89 | "remote_username":"{{user `esxi-user`}}", 90 | "remote_password":"{{user `esxi-passwd`}}", 91 | "vmx_data": { 92 | "memsize": "{{user `ram`}}", 93 | "numvcpus": "1", 94 | "cpuid.coresPerSocket": "1", 95 | "RemoteDisplay.vnc.enabled" : "TRUE", 96 | "ethernet0.startConnected": "TRUE", 97 | "ethernet0.connectiontype" : "custom", 98 | "ethernet0.virtualDev" : "e1000", 99 | "ethernet0.networkName" : "{{user `esxi-network`}}", 100 | "ethernet0.linkstatepropagation.enable" : "TRUE", 101 | "ethernet0.present" : "TRUE", 102 | "ethernet0.pcislotnumber" : "32", 103 | "ethernet1.pcislotnumber" : "33", 104 | "ethernet1.startConnected": "FALSE", 105 | "ethernet1.virtualDev" : "e1000", 106 | "ethernet1.present" : "TRUE" 107 | }, 108 | "vmx_data_post": { 109 | "ethernet1.startConnected": "TRUE" 110 | }, 111 | "shutdown_command": "/sbin/shutdown -h now", 112 | "http_directory":"http/" 113 | }, 114 | { 115 | "boot_command": [ 116 | "", 117 | "", 118 | "vmlinuz ", 119 | "initrd=initrd.img ", 120 | "biosdevname=0 net.ifnames=0 ", 121 | "inst.stage2=hd:LABEL=Fedora\\x2020\\x20x86_64 ", 122 | "rd.live.check ", 123 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-net.cfg", 124 | "" 125 | ], 126 | "boot_wait": "10s", 127 | "disk_size": "{{user `disk-size`}}", 128 | "output_directory":"{{user `name`}}-vbox", 129 | "type": "virtualbox-iso", 130 | "headless":"False", 131 | "iso_checksum": "376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f", 132 | "iso_checksum_type": "sha256", 133 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-netinst.iso", 134 | "ssh_username": "root", 135 | "ssh_password":"eosplus", 136 | "ssh_port":"22", 137 | "ssh_wait_timeout": "20m", 138 | "guest_os_type": "Fedora_64", 139 | "vm_name":"{{user `name`}}", 140 | "vboxmanage": [ 141 | [ 142 | "modifyvm", 143 | "{{.Name}}", 144 | "--memory", 145 | "{{user `ram`}}" 146 | ], 147 | [ 148 | "modifyvm", 149 | "{{.Name}}", 150 | "--cpus", 151 | "1" 152 | ], 153 | [ 154 | "modifyvm", 155 | "{{.Name}}", 156 | "--rtcuseutc", 157 | "on" 158 | ], 159 | [ 160 | "modifyvm", 161 | "{{.Name}}", 162 | "--bioslogodisplaytime", 163 | "1" 164 | ], 165 | [ 166 | "modifyvm", 167 | "{{.Name}}", 168 | "--nic1", 169 | "nat" 170 | ], 171 | [ 172 | "modifyvm", 173 | "{{.Name}}", 174 | "--nic2", 175 | "hostonly" 176 | ], 177 | [ 178 | "modifyvm", 179 | "{{.Name}}", 180 | "--hostonlyadapter2", 181 | "vboxnet2" 182 | ] 183 | ], 184 | "shutdown_command": "/sbin/shutdown -h now", 185 | "http_directory":"http/" 186 | }, 187 | { 188 | "boot_command": [ 189 | "", 190 | "", 191 | "vmlinuz ", 192 | "initrd=initrd.img ", 193 | "biosdevname=0 net.ifnames=0 ", 194 | "inst.stage2=hd:LABEL=Fedora\\x2020\\x20x86_64 ", 195 | "rd.live.check ", 196 | "inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-net.cfg", 197 | "" 198 | ], 199 | "boot_wait": "10s", 200 | "disk_size": "{{user `disk-size`}}", 201 | "output_directory":"{{user `name`}}-vbox", 202 | "type": "virtualbox-iso", 203 | "name": "virtualbox-windows-iso", 204 | "headless":"False", 205 | "iso_checksum": "376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f", 206 | "iso_checksum_type": "sha256", 207 | "iso_url": "https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-netinst.iso", 208 | "ssh_username": "root", 209 | "ssh_password":"eosplus", 210 | "ssh_port":"22", 211 | "ssh_wait_timeout": "20m", 212 | "guest_os_type": "Fedora_64", 213 | "vm_name":"{{user `name`}}", 214 | "vboxmanage": [ 215 | [ 216 | "modifyvm", 217 | "{{.Name}}", 218 | "--memory", 219 | "{{user `ram`}}" 220 | ], 221 | [ 222 | "modifyvm", 223 | "{{.Name}}", 224 | "--cpus", 225 | "1" 226 | ], 227 | [ 228 | "modifyvm", 229 | "{{.Name}}", 230 | "--pae", 231 | "off" 232 | ], 233 | [ 234 | "modifyvm", 235 | "{{.Name}}", 236 | "--hwvirtex", 237 | "on" 238 | ], 239 | [ 240 | "modifyvm", 241 | "{{.Name}}", 242 | "--vtxux", 243 | "on" 244 | ], 245 | [ 246 | "modifyvm", 247 | "{{.Name}}", 248 | "--vtxvpid", 249 | "on" 250 | ], 251 | [ 252 | "modifyvm", 253 | "{{.Name}}", 254 | "--rtcuseutc", 255 | "on" 256 | ], 257 | [ 258 | "modifyvm", 259 | "{{.Name}}", 260 | "--bioslogodisplaytime", 261 | "1" 262 | ], 263 | [ 264 | "modifyvm", 265 | "{{.Name}}", 266 | "--nic1", 267 | "nat" 268 | ], 269 | [ 270 | "modifyvm", 271 | "{{.Name}}", 272 | "--nic2", 273 | "hostonly" 274 | ], 275 | [ 276 | "modifyvm", 277 | "{{.Name}}", 278 | "--hostonlyadapter2", 279 | "VirtualBox Host-Only Ethernet Adapter #2" 280 | ] 281 | ], 282 | "shutdown_command": "/sbin/shutdown -h now", 283 | "http_directory":"http/" 284 | } 285 | ], 286 | "provisioners": [ 287 | { 288 | "source": "conf", 289 | "destination": "/tmp/packer", 290 | "type":"file" 291 | }, 292 | { 293 | "source": "files", 294 | "destination": "/tmp/packer", 295 | "type":"file" 296 | }, 297 | { 298 | "scripts": [ 299 | "scripts/setup.sh" 300 | ], 301 | "type" : "shell" 302 | } 303 | ] 304 | } 305 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Automatically Create a Full-Featured ZTPServer 2 | 3 | ##Introduction 4 | This project uses [Packer](https://packer.io) to automatically create a 5 | full-featured ZTPServer VM. 6 | By using this method, you can be sure that all of the required packages and 7 | dependencies are installed right out of the gate. 8 | This setup will include some extra services like XMPP, Syslog, NTP, DHCP, DNS, 9 | LLDPAD and others to help you get a complete testing environment running quickly. 10 | 11 | You can also use Packer to automate the setup of [vEOS nodes](https://github.com/arista-eosplus/packer-veos). 12 | 13 | ###What's Supported 14 | * **Host Operating Systems** 15 | * Windows 16 | * Mac Osx 17 | * EOS (run as a 32-bit Fedora 20 VM on EOS) 18 | * **Host Hypervisors** 19 | * VirtualBox 20 | * VMware Fusion 21 | * VMware Workstation 22 | * VMware [ESXi](#how-the-esxi-builder-works) 23 | * **VM Remote Operating Systems** 24 | * Fedora 20 25 | * Ubuntu 12.04 26 | 27 | ##Getting Started 28 | There is a nice, shiny [python script](https://github.com/arista-eosplus/packer-ztpserver/blob/master/create-ztpserver.py) 29 | that will make your life very easy! 30 | 31 | Here's what it's going to do: 32 | * Download and install [Packer](https://packer.io) to ~/packer-bin (~80MB) 33 | * Create some virtual networks. It might also change existing settings, 34 | but we'll create a backup just in case you want to revert. Check out the 35 | [details](#the-minor-details) for more information. We won't disturb **vmnet0**(Workstation), **vmnet1** and **vmnet8** in VMware which are 36 | the default networks. 37 | * Create a ZTPServer VM with the hypervisor you choose. 38 | 39 | ###Requirements 40 | * Python (this has been tested on Python 2.7.x) 41 | * [Get Python 2.7.x for Windows](https://www.python.org/downloads/windows/) 42 | * Git (technically optional but makes life easier) 43 | * [Get Git](http://git-scm.com/downloads) 44 | * User running script has sudo privileges (NIX-based) 45 | 46 | ###Go Time 47 | ####Script Arguments 48 |
 49 | arista:packer-ztpserver arista$ ./create-ztpserver.py -h
 50 | usage: create-ztpserver.py [-h] -H {vmware,esxi,virtualbox} -o
 51 |                            {fedora,ubuntu,eos} [-n VMNAME] [-d DISK_SIZE]
 52 |                            [-u ESXI_USER] [-e ESXI_HOST] [-p DATASTORE_PATH]
 53 |                            [-i ESXI_NETWORK]
 54 | 
 55 | Automatically install the ZTPServer Demo
 56 | 
 57 | optional arguments:
 58 |   -h, --help            show this help message and exit
 59 |   -H {vmware,esxi,virtualbox}, --hypervisor {vmware,esxi,virtualbox}
 60 |                         Hypervisor to create VM in
 61 |   -o {fedora,ubuntu,eos}, --os {fedora,ubuntu,eos}
 62 |                         Desired OS to use for VM
 63 |   -n VMNAME, --vmname VMNAME
 64 |                         The Virtual Machine name
 65 |   -d DISK_SIZE, --disk-size DISK_SIZE
 66 |                         VM Disk size in MB
 67 |   -u ESXI_USER, --esxi-user ESXI_USER
 68 |                         The ESXi username
 69 |   -e ESXI_HOST, --esxi-host ESXI_HOST
 70 |                         The IP or hostname of the ESXi host
 71 |   -p DATASTORE_PATH, --datastore-path DATASTORE_PATH
 72 |                         The ESXi path to save the VM
 73 |   -i ESXI_NETWORK, --esxi-network ESXI_NETWORK
 74 |                         vSphere network assigned to VM that allows
 75 |                         communication with local builder
 76 | 
77 | 78 | 1. Retrieve the ZTPServer Packer files [here](https://github.com/arista-eosplus/packer-ztpserver/archive/master.zip) or run from a shell on your local machine. 79 |
 80 |   git clone https://github.com/arista-eosplus/packer-ztpserver.git
 81 |   cd packer-ztpserver
 82 |   
83 | 2. Fire in the hole 84 | 85 | **NIX-based Terminal** 86 |
 87 |   python ./create-ztpserver.py -H [vmware|virtualbox|esxi] -o [fedora|ubuntu|eos] --vmname VMNAME-PREFIX
 88 |   
89 | > **IMPORTANT:** You will have to enter your sudo password so keep an eye on it. 90 | 91 | **Windows-based Command-Prompt** 92 | > **IMPORTANT:** Open the command prompt as an Administrator so you don't have to authorize every command 93 | 94 |
 95 |   C:\> C:\Python27\python.exe ./create-ztpserver.py -H [vmware|virtualbox|esxi] -o  [fedora|ubuntu|eos] --vmname VMNAME-PREFIX
 96 |   
97 | > **Note:** Your Python executable might be somewhere else, or part of your 98 | %PATH% in which case you could just type ```python```, but this is just 99 | meant to be a general idea. 100 | 101 | **Examples:** 102 | 103 | Create an Ubuntu ZTPServer VM for Fusion with VM name prefix "my-demo" 104 |
105 |   create-ztpserver.py -H vmware -o ubuntu --vmname my-demo
106 |   
107 | Create a Fedora ZTPServer VM for Workstation with VM name prefix "my-demo" 108 |
109 |   create-ztpserver.py -H vmware -o fedora --vmname my-demo
110 |   
111 | Create a Fedora ZTPServer VM for Fusion with 10GB disk 112 |
113 |   create-ztpserver.py -H vmware -o fedora -d 10000
114 |   
115 | Create a ZTPServer VM that runs on an EOS device 116 |
117 |   create-ztpserver.py -H vmware -o eos
118 |   
119 | Create a Fedora ZTPServer VM that runs on an ESXi host 120 |
121 |   create-ztpserver.py -H esxi -o fedora -u esxiUser -e esxi-host.example.com -p Datastore1/ztpservers -i net_vlan100
122 |   
123 | 124 | 3. When the script exits successfully you will have a full-featured ZTPServer. We've gone ahead and placed some demo files from [GitHub](https://github.com/arista-eosplus/ztpserver-demo) to make life a little easier. All of the interesting files are in ```/usr/share/ztpserver``` and ```/etc/ztpserver/```. 125 | 4. Log into the server with user ```ztpsadmin``` and password ```eosplus```. Simply type the following to start the standalone ztpserver: 126 |
127 | ztps
128 | 
129 | or to send all console output to a file: 130 | ``` 131 | ztps --debug ~/ztps-console.log 2>&1 & 132 | ``` 133 | You can stop the ztps process anytime by typing 134 |
135 |   pkill ztps
136 |   
137 | You can also run the ZTPServer as an Apache Web Server Gateway Interface. All of the necessary config is already in place. Just start Apache: 138 | > **Note:** The ZTPServer can only run in Standalone mode OR as an WSGI App. Kill the ztps process first if you would like to run the WSGI App. 139 | 140 |
141 |   systemctl start httpd
142 |   systemctl enable httpd
143 |   
144 | WSGI related logs will be in ```/var/log/messages``` and ```/var/log/httpd/error.log``` 145 | Refer to the [ZTPServer Documentation](http://ztpserver.readthedocs.org/en/develop/) to learn how to customize your ZTPServer. You can create some [vEOS](https://github.com/arista-eosplus/packer-veos) nodes using Packer to help get your demo working even faster. 146 | 147 | ###Post-Installation Tips 148 | ####Set the PATH Variable 149 | If Packer is installed via the script above, the packer binary path wasn't permanently 150 | added to your system ```PATH``` variable. If you intend on using Packer again, you might consider 151 | updating your ```PATH``` variable. 152 | 153 | **NIX-Based Terminal** 154 |
155 | echo "export PATH=$PATH:~/packer-bin" >> ~/.bash_profile
156 | 
157 | and then restart your bash. 158 | 159 | **Windows-Based Command Prompt** 160 |
161 | setx PATH "%PATH%;%USERPROFILE%\packer-bin"
162 | 
163 | and then restart your ```cmd.exe```. 164 | 165 | ####Upload the EOS VM to an Arista Switch 166 | **Step 1:** First SCP the resulting .vmdk file to your Arista switch 167 | ``` 168 | scp disk.vmdk admin@eos-switch-1:/mnt/dst/path 169 | ``` 170 | **Step 2:** Create Virtual-Machine entry. Log into your EOS switch: 171 | ``` 172 | eos-switch-1#conf 173 | eos-switch-1(config)#virtual-machine ztps 174 | eos-switch-1(config-ztps)#disk-image usb1:/path/disk.vmdk image-format vmdk 175 | eos-switch-1(config-ztps)#memory-size 1024 ! Choose a desired size 176 | eos-switch-1(config-ztps)#enable 177 | ``` 178 | **Step 3:** Confirm the VM is running 179 | ``` 180 | eos-switch-1#show virtual-machine 181 | VM Name Enabled State 182 | ------- ------- ----- 183 | ztps Yes Running 184 | ``` 185 | **Step 4:** Console into the ZTPServer VM 186 | ``` 187 | eos-switch-1#bash 188 | [admin@eos-switch-1 ~]$ sudo virsh 189 | virsh # list 190 | Id Name State 191 | ---------------------------------- 192 | 1 ztps running 193 | 194 | virsh # console 1 195 | error: Failed to get local hostname 196 | error: Failed to get connection hostname 197 | Connected to domain ztps 198 | Escape character is ^] 199 | 200 | [root@ztps ~]# echo hello world 201 | ``` 202 | 203 | ##The Minor Details 204 | ###How the ESXi Builder Works 205 | Packer provides built-in support for VM creation on VMware ESXi. In this case, 206 | you still execute the ```create-ztpserver``` script on your local machine, but 207 | you provide details for Packer to upload and create the VM on your ESXi host. 208 | 209 | ####Require Parameters 210 | * ```-u``` ESXi Username: This is the username used to log into your ESXi host 211 | * ```-e``` ESXi Host: The IP or resolvable hostname of your ESXi host 212 | * ```-p``` ESXi Datastore path: This is where the script will copy your VM to. Typically it looks something like ```Datastore-1/path/to/dir``` 213 | * ```-i``` ESXi Network Name: Your local machine and the VM must be able to communicate. So this must be the network that provides that network connectivity. 214 | 215 | ###Virtual Networks 216 | Host-only virtual networks will be created: 217 | * vboxnet2/vmnet2 218 | * Used for Eth1 on the ZTPServer. This is the internal management network 219 | * DHCP off 220 | * NAT off 221 | * vboxnet3/vmnet3 222 | * Proactively created for use with vEOS demo - data network 223 | * DHCP off 224 | * NAT off 225 | * vboxnet4/vmnet4 226 | * Proactively created for use with vEOS demo - data network 227 | * DHCP off 228 | * NAT off 229 | * vboxnet5/vmnet5 230 | * Proactively created for use with vEOS demo - data network 231 | * DHCP off 232 | * NAT off 233 | * vboxnet6/vmnet6 234 | * Proactively created for use with vEOS demo - data network 235 | * DHCP off 236 | * NAT off 237 | * vboxnet7/vmnet7 238 | * Proactively created for use with vEOS demo - data network 239 | * DHCP off 240 | * NAT off 241 | * vboxnet9/vmnet9 242 | * Proactively created for use with vEOS demo - data network 243 | * DHCP off 244 | * NAT off 245 | * vboxnet10/vmnet10 246 | * Proactively created for use with vEOS demo - data network 247 | * DHCP off 248 | * NAT off 249 | 250 | ###The ZTPServer VM 251 | * 7GB Hard Drive 252 | * 2GB RAM 253 | * Python 2.7.x with Pip 254 | * Hostname ztps.ztps-test.com 255 | * eth0 (NAT) DHCP 256 | * eth1 (vboxnet2/vmnet2) 172.16.130.10/24 257 | * Firewall disabled. 258 | * Users 259 | * root/eosplus and ztpsadmin/eosplus 260 | * DHCP installed with Option 67 configured (eth1 only) 261 | * BIND DNS server installed with zone ztps-test.com 262 | * wildcard forward rule to 8.8.8.8 for all other queries 263 | * rsyslog-ng installed; Listening on UDP and TCP (port 514) 264 | * XMPP server configured for im.ztps-test.com 265 | * XMPP admin user ztpsadmin@im.ztps-test.com, passwd eosplus 266 | * httpd installed and configured for ZTPServer (mod_wsgi). The configuration files are in place, but httpd is not running by default. 267 | * ZTPServer installed (with [sample files](https://github.com/arista-eosplus/ztpserver-demo) to get you up and running) 268 | 269 | If you run into any snags, please feel free to raise an issue and attach the 270 | logs. 271 | -------------------------------------------------------------------------------- /Ubuntu/ztps-ubuntu-12.04.4_amd64.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "ram": "2048", 4 | "disk-size": "7000", 5 | "name": "ztps-ubuntu-12.04_amd64", 6 | "esxi-user": "", 7 | "esxi-passwd": "", 8 | "esxi-host": "", 9 | "esxi-path": "", 10 | "esxi-network": "" 11 | }, 12 | "builders": [ 13 | { 14 | "boot_command": [ 15 | "", 16 | "", 17 | "", 18 | "/install/vmlinuz", 19 | " auto", 20 | " console-setup/ask_detect=false", 21 | " console-setup/layoutcode=us", 22 | " console-setup/modelcode=pc105", 23 | " debconf/frontend=noninteractive", 24 | " debian-installer=en_US", 25 | " fb=false", 26 | " initrd=/install/initrd.gz", 27 | " kbd-chooser/method=us", 28 | " keyboard-configuration/layout=USA", 29 | " keyboard-configuration/variant=USA", 30 | " locale=en_US", 31 | " netcfg/choose_interface=eth0", 32 | " netcfg/get_hostname=ztps", 33 | " netcfg/get_domain=ztps-test.com", 34 | " noapic", 35 | " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", 36 | " -- ", 37 | "" 38 | ], 39 | "boot_wait": "10s", 40 | "disk_size": "{{user `disk-size`}}", 41 | "output_directory":"{{user `name`}}-vmware", 42 | "type": "vmware-iso", 43 | "headless":"False", 44 | "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9", 45 | "iso_checksum_type": "sha256", 46 | "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso", 47 | "ssh_username": "root", 48 | "ssh_password":"eosplus", 49 | "ssh_port":"22", 50 | "ssh_wait_timeout": "20m", 51 | "guest_os_type": "linux", 52 | "vm_name":"{{user `name`}}", 53 | "vmx_data": { 54 | "memsize": "{{user `ram`}}", 55 | "numvcpus": "1", 56 | "cpuid.coresPerSocket": "1", 57 | "ethernet0.present" : "TRUE", 58 | "ethernet0.virtualdev" : "e1000", 59 | "ethernet0.connectionType" : "nat", 60 | "ethernet0.startConnected" : "TRUE", 61 | "ethernet0.pcislotnumber" : "32", 62 | "ethernet1.pcislotnumber" : "33", 63 | "ethernet1.virtualdev" : "e1000", 64 | "ethernet1.present" : "TRUE", 65 | "ethernet1.startConnected" : "TRUE", 66 | "ethernet1.connectionType" : "custom", 67 | "ethernet1.vnet":"vmnet2" 68 | }, 69 | "shutdown_command": "/sbin/shutdown -h now", 70 | "http_directory":"http/" 71 | }, 72 | { 73 | "boot_command": [ 74 | "", 75 | "", 76 | "", 77 | "/install/vmlinuz", 78 | " auto", 79 | " console-setup/ask_detect=false", 80 | " console-setup/layoutcode=us", 81 | " console-setup/modelcode=pc105", 82 | " debconf/frontend=noninteractive", 83 | " debian-installer=en_US", 84 | " fb=false", 85 | " initrd=/install/initrd.gz", 86 | " kbd-chooser/method=us", 87 | " keyboard-configuration/layout=USA", 88 | " keyboard-configuration/variant=USA", 89 | " locale=en_US", 90 | " netcfg/choose_interface=eth0", 91 | " netcfg/get_hostname=ztps", 92 | " netcfg/get_domain=ztps-test.com", 93 | " noapic", 94 | " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", 95 | " -- ", 96 | "" 97 | ], 98 | "boot_wait": "10s", 99 | "disk_size": "{{user `disk-size`}}", 100 | "disk_type_id": "thin", 101 | "output_directory":"{{user `name`}}-vmware", 102 | "type": "vmware-iso", 103 | "name": "esxi-iso", 104 | "headless":"False", 105 | "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9", 106 | "iso_checksum_type": "sha256", 107 | "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso", 108 | "ssh_username": "root", 109 | "ssh_password":"eosplus", 110 | "ssh_port":"22", 111 | "ssh_wait_timeout": "20m", 112 | "guest_os_type": "ubuntu-64", 113 | "vm_name":"{{user `name`}}", 114 | "remote_host":"{{user `esxi-host`}}", 115 | "remote_datastore":"{{user `esxi-path`}}", 116 | "remote_type":"esx5", 117 | "remote_username":"{{user `esxi-user`}}", 118 | "remote_password":"{{user `esxi-passwd`}}", 119 | "vmx_data": { 120 | "memsize": "{{user `ram`}}", 121 | "numvcpus": "1", 122 | "cpuid.coresPerSocket": "1", 123 | "RemoteDisplay.vnc.enabled" : "TRUE", 124 | "ethernet0.startConnected": "TRUE", 125 | "ethernet0.connectiontype" : "custom", 126 | "ethernet0.virtualDev" : "e1000", 127 | "ethernet0.networkName" : "{{user `esxi-network`}}", 128 | "ethernet0.linkstatepropagation.enable" : "TRUE", 129 | "ethernet0.present" : "TRUE", 130 | "ethernet0.pcislotnumber" : "32", 131 | "ethernet1.pcislotnumber" : "33", 132 | "ethernet1.startConnected": "FALSE", 133 | "ethernet1.virtualDev" : "e1000", 134 | "ethernet1.present" : "TRUE" 135 | }, 136 | "vmx_data_post": { 137 | "ethernet1.startConnected": "TRUE" 138 | }, 139 | "shutdown_command": "/sbin/shutdown -h now", 140 | "http_directory":"http/" 141 | }, 142 | { 143 | "boot_command": [ 144 | "", 145 | "", 146 | "", 147 | "/install/vmlinuz", 148 | " auto", 149 | " console-setup/ask_detect=false", 150 | " console-setup/layoutcode=us", 151 | " console-setup/modelcode=pc105", 152 | " debconf/frontend=noninteractive", 153 | " debian-installer=en_US", 154 | " fb=false", 155 | " initrd=/install/initrd.gz", 156 | " kbd-chooser/method=us", 157 | " keyboard-configuration/layout=USA", 158 | " keyboard-configuration/variant=USA", 159 | " locale=en_US", 160 | " netcfg/choose_interface=eth0", 161 | " netcfg/get_hostname=ztps", 162 | " netcfg/get_domain=ztps-test.com", 163 | " noapic", 164 | " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", 165 | " -- ", 166 | "" 167 | ], 168 | "boot_wait": "10s", 169 | "disk_size": "{{user `disk-size`}}", 170 | "output_directory":"{{user `name`}}-vbox", 171 | "type": "virtualbox-iso", 172 | "headless":"False", 173 | "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9", 174 | "iso_checksum_type": "sha256", 175 | "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso", 176 | "ssh_username": "root", 177 | "ssh_password":"eosplus", 178 | "ssh_port":"22", 179 | "ssh_wait_timeout": "20m", 180 | "guest_os_type": "Ubuntu_64", 181 | "vm_name":"{{user `name`}}", 182 | "vboxmanage": [ 183 | [ 184 | "modifyvm", 185 | "{{.Name}}", 186 | "--memory", 187 | "{{user `ram`}}" 188 | ], 189 | [ 190 | "modifyvm", 191 | "{{.Name}}", 192 | "--cpus", 193 | "1" 194 | ], 195 | [ 196 | "modifyvm", 197 | "{{.Name}}", 198 | "--rtcuseutc", 199 | "on" 200 | ], 201 | [ 202 | "modifyvm", 203 | "{{.Name}}", 204 | "--bioslogodisplaytime", 205 | "1" 206 | ], 207 | [ 208 | "modifyvm", 209 | "{{.Name}}", 210 | "--nic1", 211 | "nat" 212 | ], 213 | [ 214 | "modifyvm", 215 | "{{.Name}}", 216 | "--nic2", 217 | "hostonly" 218 | ], 219 | [ 220 | "modifyvm", 221 | "{{.Name}}", 222 | "--hostonlyadapter2", 223 | "vboxnet2" 224 | ] 225 | ], 226 | "shutdown_command": "/sbin/shutdown -h now", 227 | "http_directory":"http/" 228 | }, 229 | { 230 | "boot_command": [ 231 | "", 232 | "", 233 | "", 234 | "/install/vmlinuz", 235 | " auto", 236 | " console-setup/ask_detect=false", 237 | " console-setup/layoutcode=us", 238 | " console-setup/modelcode=pc105", 239 | " debconf/frontend=noninteractive", 240 | " debian-installer=en_US", 241 | " fb=false", 242 | " initrd=/install/initrd.gz", 243 | " kbd-chooser/method=us", 244 | " keyboard-configuration/layout=USA", 245 | " keyboard-configuration/variant=USA", 246 | " locale=en_US", 247 | " netcfg/choose_interface=eth0", 248 | " netcfg/get_hostname=ztps", 249 | " netcfg/get_domain=ztps-test.com", 250 | " noapic", 251 | " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", 252 | " -- ", 253 | "" 254 | ], 255 | "boot_wait": "10s", 256 | "disk_size": "{{user `disk-size`}}", 257 | "output_directory":"{{user `name`}}-vbox", 258 | "type": "virtualbox-iso", 259 | "name": "virtualbox-windows-iso", 260 | "headless":"False", 261 | "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9", 262 | "iso_checksum_type": "sha256", 263 | "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso", 264 | "ssh_username": "root", 265 | "ssh_password":"eosplus", 266 | "ssh_port":"22", 267 | "ssh_wait_timeout": "20m", 268 | "guest_os_type": "Ubuntu_64", 269 | "vm_name":"{{user `name`}}", 270 | "vboxmanage": [ 271 | [ 272 | "modifyvm", 273 | "{{.Name}}", 274 | "--memory", 275 | "{{user `ram`}}" 276 | ], 277 | [ 278 | "modifyvm", 279 | "{{.Name}}", 280 | "--cpus", 281 | "1" 282 | ], 283 | [ 284 | "modifyvm", 285 | "{{.Name}}", 286 | "--rtcuseutc", 287 | "on" 288 | ], 289 | [ 290 | "modifyvm", 291 | "{{.Name}}", 292 | "--bioslogodisplaytime", 293 | "1" 294 | ], 295 | [ 296 | "modifyvm", 297 | "{{.Name}}", 298 | "--hwvirtex", 299 | "on" 300 | ], 301 | [ 302 | "modifyvm", 303 | "{{.Name}}", 304 | "--vtxux", 305 | "on" 306 | ], 307 | [ 308 | "modifyvm", 309 | "{{.Name}}", 310 | "--vtxvpid", 311 | "on" 312 | ], 313 | [ 314 | "modifyvm", 315 | "{{.Name}}", 316 | "--nic1", 317 | "nat" 318 | ], 319 | [ 320 | "modifyvm", 321 | "{{.Name}}", 322 | "--nic2", 323 | "hostonly" 324 | ], 325 | [ 326 | "modifyvm", 327 | "{{.Name}}", 328 | "--hostonlyadapter2", 329 | "VirtualBox Host-Only Ethernet Adapter #2" 330 | ] 331 | ], 332 | "shutdown_command": "/sbin/shutdown -h now", 333 | "http_directory":"http/" 334 | } 335 | ], 336 | "provisioners": [ 337 | { 338 | "source": "conf", 339 | "destination": "/tmp/packer", 340 | "type":"file" 341 | }, 342 | { 343 | "source": "files", 344 | "destination": "/tmp/packer", 345 | "type":"file" 346 | }, 347 | { 348 | "scripts": [ 349 | "scripts/setup.sh" 350 | ], 351 | "type" : "shell" 352 | } 353 | ] 354 | } 355 | -------------------------------------------------------------------------------- /Fedora/conf/httpd.conf: -------------------------------------------------------------------------------- 1 | # 2 | # This is the main Apache HTTP server configuration file. It contains the 3 | # configuration directives that give the server its instructions. 4 | # See for detailed information. 5 | # In particular, see 6 | # 7 | # for a discussion of each configuration directive. 8 | # 9 | # Do NOT simply read the instructions in here without understanding 10 | # what they do. They're here only as hints or reminders. If you are unsure 11 | # consult the online docs. You have been warned. 12 | # 13 | # Configuration and logfile names: If the filenames you specify for many 14 | # of the server's control files begin with "/" (or "drive:/" for Win32), the 15 | # server will use that explicit path. If the filenames do *not* begin 16 | # with "/", the value of ServerRoot is prepended -- so 'log/access_log' 17 | # with ServerRoot set to '/www' will be interpreted by the 18 | # server as '/www/log/access_log', where as '/log/access_log' will be 19 | # interpreted as '/log/access_log'. 20 | 21 | # 22 | # ServerRoot: The top of the directory tree under which the server's 23 | # configuration, error, and log files are kept. 24 | # 25 | # Do not add a slash at the end of the directory path. If you point 26 | # ServerRoot at a non-local disk, be sure to specify a local disk on the 27 | # Mutex directive, if file-based mutexes are used. If you wish to share the 28 | # same ServerRoot for multiple httpd daemons, you will need to change at 29 | # least PidFile. 30 | # 31 | ServerRoot "/etc/httpd" 32 | 33 | # 34 | # Listen: Allows you to bind Apache to specific IP addresses and/or 35 | # ports, instead of the default. See also the 36 | # directive. 37 | # 38 | # Change this to Listen on specific IP addresses as shown below to 39 | # prevent Apache from glomming onto all bound IP addresses. 40 | # 41 | #Listen 12.34.56.78:80 42 | Listen 80 43 | Listen 8080 44 | 45 | # 46 | # Dynamic Shared Object (DSO) Support 47 | # 48 | # To be able to use the functionality of a module which was built as a DSO you 49 | # have to place corresponding `LoadModule' lines at this location so the 50 | # directives contained in it are actually available _before_ they are used. 51 | # Statically compiled modules (those listed by `httpd -l') do not need 52 | # to be loaded here. 53 | # 54 | # Example: 55 | # LoadModule foo_module modules/mod_foo.so 56 | # 57 | Include conf.modules.d/*.conf 58 | 59 | # 60 | # If you wish httpd to run as a different user or group, you must run 61 | # httpd as root initially and it will switch. 62 | # 63 | # User/Group: The name (or #number) of the user/group to run httpd as. 64 | # It is usually good practice to create a dedicated user and group for 65 | # running httpd, as with most system services. 66 | # 67 | User apache 68 | Group apache 69 | 70 | # 'Main' server configuration 71 | # 72 | # The directives in this section set up the values used by the 'main' 73 | # server, which responds to any requests that aren't handled by a 74 | # definition. These values also provide defaults for 75 | # any containers you may define later in the file. 76 | # 77 | # All of these directives may appear inside containers, 78 | # in which case these default settings will be overridden for the 79 | # virtual host being defined. 80 | # 81 | 82 | # 83 | # ServerAdmin: Your address, where problems with the server should be 84 | # e-mailed. This address appears on some server-generated pages, such 85 | # as error documents. e.g. admin@your-domain.com 86 | # 87 | ServerAdmin root@ztps-test.com 88 | 89 | # 90 | # ServerName gives the name and port that the server uses to identify itself. 91 | # This can often be determined automatically, but we recommend you specify 92 | # it explicitly to prevent problems during startup. 93 | # 94 | # If your host doesn't have a registered DNS name, enter its IP address here. 95 | # 96 | #ServerName www.example.com:80 97 | 98 | # 99 | # Deny access to the entirety of your server's filesystem. You must 100 | # explicitly permit access to web content directories in other 101 | # blocks below. 102 | # 103 | 104 | AllowOverride none 105 | Require all denied 106 | 107 | 108 | # 109 | # Note that from this point forward you must specifically allow 110 | # particular features to be enabled - so if something's not working as 111 | # you might expect, make sure that you have specifically enabled it 112 | # below. 113 | # 114 | 115 | # 116 | # DocumentRoot: The directory out of which you will serve your 117 | # documents. By default, all requests are taken from this directory, but 118 | # symbolic links and aliases may be used to point to other locations. 119 | # 120 | DocumentRoot "/var/www/html" 121 | 122 | # 123 | # Relax access to content within /var/www. 124 | # 125 | 126 | AllowOverride None 127 | # Allow open access: 128 | Require all granted 129 | 130 | 131 | # Further relax access to the default document root: 132 | 133 | # 134 | # Possible values for the Options directive are "None", "All", 135 | # or any combination of: 136 | # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 137 | # 138 | # Note that "MultiViews" must be named *explicitly* --- "Options All" 139 | # doesn't give it to you. 140 | # 141 | # The Options directive is both complicated and important. Please see 142 | # http://httpd.apache.org/docs/2.4/mod/core.html#options 143 | # for more information. 144 | # 145 | Options Indexes FollowSymLinks 146 | 147 | # 148 | # AllowOverride controls what directives may be placed in .htaccess files. 149 | # It can be "All", "None", or any combination of the keywords: 150 | # Options FileInfo AuthConfig Limit 151 | # 152 | AllowOverride None 153 | 154 | # 155 | # Controls who can get stuff from this server. 156 | # 157 | Require all granted 158 | 159 | 160 | # 161 | # DirectoryIndex: sets the file that Apache will serve if a directory 162 | # is requested. 163 | # 164 | 165 | DirectoryIndex index.html 166 | 167 | 168 | # 169 | # The following lines prevent .htaccess and .htpasswd files from being 170 | # viewed by Web clients. 171 | # 172 | 173 | Require all denied 174 | 175 | 176 | # 177 | # ErrorLog: The location of the error log file. 178 | # If you do not specify an ErrorLog directive within a 179 | # container, error messages relating to that virtual host will be 180 | # logged here. If you *do* define an error logfile for a 181 | # container, that host's errors will be logged there and not here. 182 | # 183 | ErrorLog "logs/error_log" 184 | 185 | # 186 | # LogLevel: Control the number of messages logged to the error_log. 187 | # Possible values include: debug, info, notice, warn, error, crit, 188 | # alert, emerg. 189 | # 190 | LogLevel warn 191 | 192 | 193 | # 194 | # The following directives define some format nicknames for use with 195 | # a CustomLog directive (see below). 196 | # 197 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 198 | LogFormat "%h %l %u %t \"%r\" %>s %b" common 199 | 200 | 201 | # You need to enable mod_logio.c to use %I and %O 202 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 203 | 204 | 205 | # 206 | # The location and format of the access logfile (Common Logfile Format). 207 | # If you do not define any access logfiles within a 208 | # container, they will be logged here. Contrariwise, if you *do* 209 | # define per- access logfiles, transactions will be 210 | # logged therein and *not* in this file. 211 | # 212 | #CustomLog "logs/access_log" common 213 | 214 | # 215 | # If you prefer a logfile with access, agent, and referer information 216 | # (Combined Logfile Format) you can use the following directive. 217 | # 218 | CustomLog "logs/access_log" combined 219 | 220 | 221 | 222 | # 223 | # Redirect: Allows you to tell clients about documents that used to 224 | # exist in your server's namespace, but do not anymore. The client 225 | # will make a new request for the document at its new location. 226 | # Example: 227 | # Redirect permanent /foo http://www.example.com/bar 228 | 229 | # 230 | # Alias: Maps web paths into filesystem paths and is used to 231 | # access content that does not live under the DocumentRoot. 232 | # Example: 233 | # Alias /webpath /full/filesystem/path 234 | # 235 | # If you include a trailing / on /webpath then the server will 236 | # require it to be present in the URL. You will also likely 237 | # need to provide a section to allow access to 238 | # the filesystem path. 239 | 240 | # 241 | # ScriptAlias: This controls which directories contain server scripts. 242 | # ScriptAliases are essentially the same as Aliases, except that 243 | # documents in the target directory are treated as applications and 244 | # run by the server when requested rather than as documents sent to the 245 | # client. The same rules about trailing "/" apply to ScriptAlias 246 | # directives as to Alias. 247 | # 248 | ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 249 | 250 | 251 | 252 | # 253 | # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased 254 | # CGI directory exists, if you have that configured. 255 | # 256 | 257 | AllowOverride None 258 | Options None 259 | Require all granted 260 | 261 | 262 | 263 | # 264 | # TypesConfig points to the file containing the list of mappings from 265 | # filename extension to MIME-type. 266 | # 267 | TypesConfig /etc/mime.types 268 | 269 | # 270 | # AddType allows you to add to or override the MIME configuration 271 | # file specified in TypesConfig for specific file types. 272 | # 273 | #AddType application/x-gzip .tgz 274 | # 275 | # AddEncoding allows you to have certain browsers uncompress 276 | # information on the fly. Note: Not all browsers support this. 277 | # 278 | #AddEncoding x-compress .Z 279 | #AddEncoding x-gzip .gz .tgz 280 | # 281 | # If the AddEncoding directives above are commented-out, then you 282 | # probably should define those extensions to indicate media types: 283 | # 284 | AddType application/x-compress .Z 285 | AddType application/x-gzip .gz .tgz 286 | 287 | # 288 | # AddHandler allows you to map certain file extensions to "handlers": 289 | # actions unrelated to filetype. These can be either built into the server 290 | # or added with the Action directive (see below) 291 | # 292 | # To use CGI scripts outside of ScriptAliased directories: 293 | # (You will also need to add "ExecCGI" to the "Options" directive.) 294 | # 295 | #AddHandler cgi-script .cgi 296 | 297 | # For type maps (negotiated resources): 298 | #AddHandler type-map var 299 | 300 | # 301 | # Filters allow you to process content before it is sent to the client. 302 | # 303 | # To parse .shtml files for server-side includes (SSI): 304 | # (You will also need to add "Includes" to the "Options" directive.) 305 | # 306 | AddType text/html .shtml 307 | AddOutputFilter INCLUDES .shtml 308 | 309 | 310 | # 311 | # Specify a default charset for all content served; this enables 312 | # interpretation of all content as UTF-8 by default. To use the 313 | # default browser choice (ISO-8859-1), or to allow the META tags 314 | # in HTML content to override this choice, comment out this 315 | # directive: 316 | # 317 | AddDefaultCharset UTF-8 318 | 319 | 320 | # 321 | # The mod_mime_magic module allows the server to use various hints from the 322 | # contents of the file itself to determine its type. The MIMEMagicFile 323 | # directive tells the module where the hint definitions are located. 324 | # 325 | MIMEMagicFile conf/magic 326 | 327 | 328 | # 329 | # Customizable error responses come in three flavors: 330 | # 1) plain text 2) local redirects 3) external redirects 331 | # 332 | # Some examples: 333 | #ErrorDocument 500 "The server made a boo boo." 334 | #ErrorDocument 404 /missing.html 335 | #ErrorDocument 404 "/cgi-bin/missing_handler.pl" 336 | #ErrorDocument 402 http://www.example.com/subscription_info.html 337 | # 338 | 339 | # 340 | # EnableMMAP and EnableSendfile: On systems that support it, 341 | # memory-mapping or the sendfile syscall may be used to deliver 342 | # files. This usually improves server performance, but must 343 | # be turned off when serving from networked-mounted 344 | # filesystems or if support for these functions is otherwise 345 | # broken on your system. 346 | # Defaults if commented: EnableMMAP On, EnableSendfile Off 347 | # 348 | #EnableMMAP off 349 | EnableSendfile on 350 | 351 | # Supplemental configuration 352 | # 353 | # Load config files in the "/etc/httpd/conf.d" directory, if any. 354 | IncludeOptional conf.d/*.conf 355 | 356 | 357 | ########################################## 358 | # ZTPSERVER-RELATED CONFIGURATION 359 | ########################################## 360 | 361 | LoadModule wsgi_module modules/mod_wsgi.so 362 | 363 | 364 | WSGIDaemonProcess ztpserver user=ztpsadmin group=ztpsadmin threads=25 365 | WSGIScriptAlias / /etc/ztpserver/ztpserver.wsgi 366 | 367 | 368 | WSGIProcessGroup ztpserver 369 | WSGIApplicationGroup %{GLOBAL} 370 | Require all granted 371 | 372 | -------------------------------------------------------------------------------- /Fedora/conf/ejabberd.cfg: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% ejabberd configuration file 3 | %%% 4 | %%%' 5 | 6 | %%% The parameters used in this configuration file are explained in more detail 7 | %%% in the ejabberd Installation and Operation Guide. 8 | %%% Please consult the Guide in case of doubts, it is included with 9 | %%% your copy of ejabberd, and is also available online at 10 | %%% http://www.process-one.net/en/ejabberd/docs/ 11 | 12 | %%% This configuration file contains Erlang terms. 13 | %%% In case you want to understand the syntax, here are the concepts: 14 | %%% 15 | %%% - The character to comment a line is % 16 | %%% 17 | %%% - Each term ends in a dot, for example: 18 | %%% override_global. 19 | %%% 20 | %%% - A tuple has a fixed definition, its elements are 21 | %%% enclosed in {}, and separated with commas: 22 | %%% {loglevel, 4}. 23 | %%% 24 | %%% - A list can have as many elements as you want, 25 | %%% and is enclosed in [], for example: 26 | %%% [http_poll, web_admin, tls] 27 | %%% 28 | %%% - A keyword of ejabberd is a word in lowercase. 29 | %%% Strings are enclosed in "" and can contain spaces, dots, ... 30 | %%% {language, "en"}. 31 | %%% {ldap_rootdn, "dc=example,dc=com"}. 32 | %%% 33 | %%% - This term includes a tuple, a keyword, a list, and two strings: 34 | %%% {hosts, ["jabber.example.net", "im.example.com"]}. 35 | %%% 36 | 37 | 38 | %%%. ======================= 39 | %%%' OVERRIDE STORED OPTIONS 40 | 41 | %% 42 | %% Override the old values stored in the database. 43 | %% 44 | 45 | %% 46 | %% Override global options (shared by all ejabberd nodes in a cluster). 47 | %% 48 | %%override_global. 49 | 50 | %% 51 | %% Override local options (specific for this particular ejabberd node). 52 | %% 53 | %%override_local. 54 | 55 | %% 56 | %% Remove the Access Control Lists before new ones are added. 57 | %% 58 | %%override_acls. 59 | 60 | 61 | %%%. ========= 62 | %%%' DEBUGGING 63 | 64 | %% 65 | %% loglevel: Verbosity of log files generated by ejabberd. 66 | %% 0: No ejabberd log at all (not recommended) 67 | %% 1: Critical 68 | %% 2: Error 69 | %% 3: Warning 70 | %% 4: Info 71 | %% 5: Debug 72 | %% 73 | {loglevel, 5}. 74 | 75 | %% 76 | %% watchdog_admins: Only useful for developers: if an ejabberd process 77 | %% consumes a lot of memory, send live notifications to these XMPP 78 | %% accounts. 79 | %% 80 | %%{watchdog_admins, ["bob@example.com"]}. 81 | 82 | 83 | %%%. ================ 84 | %%%' SERVED HOSTNAMES 85 | 86 | %% 87 | %% hosts: Domains served by ejabberd. 88 | %% You can define one or several, for example: 89 | %% {hosts, ["example.net", "example.com", "example.org"]}. 90 | %% 91 | {hosts, ["im.ztps-test.com"]}. 92 | 93 | %% 94 | %% route_subdomains: Delegate subdomains to other XMPP servers. 95 | %% For example, if this ejabberd serves example.org and you want 96 | %% to allow communication with an XMPP server called im.example.org. 97 | %% 98 | %%{route_subdomains, s2s}. 99 | 100 | 101 | %%%. =============== 102 | %%%' LISTENING PORTS 103 | 104 | %% 105 | %% listen: The ports ejabberd will listen on, which service each is handled 106 | %% by and what options to start it with. 107 | %% 108 | {listen, 109 | [ 110 | 111 | {5222, ejabberd_c2s, [ 112 | 113 | %% 114 | %% If TLS is compiled in and you installed a SSL 115 | %% certificate, specify the full path to the 116 | %% file and uncomment this line: 117 | %% 118 | %%{certfile, "/etc/ejabberd/ejabberd.pem"}, starttls, 119 | 120 | {access, c2s}, 121 | {shaper, c2s_shaper}, 122 | {max_stanza_size, 65536} 123 | ]}, 124 | 125 | %% 126 | %% To enable the old SSL connection method on port 5223: 127 | %% 128 | %%{5223, ejabberd_c2s, [ 129 | %% {access, c2s}, 130 | %% {shaper, c2s_shaper}, 131 | %% {certfile, "/etc/ejabberd/ejabberd.pem"}, tls, 132 | %% {max_stanza_size, 65536} 133 | %% ]}, 134 | 135 | {5269, ejabberd_s2s_in, [ 136 | {shaper, s2s_shaper}, 137 | {max_stanza_size, 131072} 138 | ]}, 139 | 140 | %% 141 | %% ejabberd_service: Interact with external components (transports, ...) 142 | %% 143 | %%{8888, ejabberd_service, [ 144 | %% {access, all}, 145 | %% {shaper_rule, fast}, 146 | %% {ip, {127, 0, 0, 1}}, 147 | %% {hosts, ["icq.example.org", "sms.example.org"], 148 | %% [{password, "secret"}] 149 | %% } 150 | %% ]}, 151 | 152 | %% 153 | %% ejabberd_stun: Handles STUN Binding requests 154 | %% 155 | %%{{3478, udp}, ejabberd_stun, []}, 156 | 157 | {5280, ejabberd_http, [ 158 | %% %%{request_handlers, 159 | %% %% [ 160 | %% %% {["pub", "archive"], mod_http_fileserver} 161 | %% %% ]}, 162 | %%captcha, 163 | http_bind, 164 | http_poll, 165 | %%register, 166 | web_admin 167 | ]} 168 | 169 | ]}. 170 | 171 | %% 172 | %% s2s_use_starttls: Enable STARTTLS + Dialback for S2S connections. 173 | %% Allowed values are: false optional required required_trusted 174 | %% You must specify a certificate file. 175 | %% 176 | %%{s2s_use_starttls, optional}. 177 | 178 | %% 179 | %% s2s_certfile: Specify a certificate file. 180 | %% 181 | %%{s2s_certfile, "/etc/ejabberd/ejabberd.pem"}. 182 | 183 | %% 184 | %% domain_certfile: Specify a different certificate for each served hostname. 185 | %% 186 | %%{domain_certfile, "example.org", "/path/to/example_org.pem"}. 187 | %%{domain_certfile, "example.com", "/path/to/example_com.pem"}. 188 | 189 | %% 190 | %% S2S whitelist or blacklist 191 | %% 192 | %% Default s2s policy for undefined hosts. 193 | %% 194 | %%{s2s_default_policy, allow}. 195 | 196 | %% 197 | %% Allow or deny communication with specific servers. 198 | %% 199 | %%{{s2s_host, "goodhost.org"}, allow}. 200 | %%{{s2s_host, "badhost.org"}, deny}. 201 | 202 | %% 203 | %% Outgoing S2S options 204 | %% 205 | %% Preferred address families (which to try first) and connect timeout 206 | %% in milliseconds. 207 | %% 208 | %%{outgoing_s2s_options, [ipv4, ipv6], 10000}. 209 | 210 | 211 | %%%. ============== 212 | %%%' AUTHENTICATION 213 | 214 | %% 215 | %% auth_method: Method used to authenticate the users. 216 | %% The default method is the internal. 217 | %% If you want to use a different method, 218 | %% comment this line and enable the correct ones. 219 | %% 220 | {auth_method, internal}. 221 | %% 222 | %% Store the plain passwords or hashed for SCRAM: 223 | %%{auth_password_format, plain}. 224 | %%{auth_password_format, scram}. 225 | %% 226 | %% Define the FQDN if ejabberd doesn't detect it: 227 | %%{fqdn, "server3.example.com"}. 228 | 229 | %% 230 | %% Authentication using external script 231 | %% Make sure the script is executable by ejabberd. 232 | %% 233 | %%{auth_method, external}. 234 | %%{extauth_program, "/path/to/authentication/script"}. 235 | 236 | %% 237 | %% Authentication using ODBC 238 | %% Remember to setup a database in the next section. 239 | %% 240 | %%{auth_method, odbc}. 241 | 242 | %% 243 | %% Authentication using PAM 244 | %% 245 | %%{auth_method, pam}. 246 | %%{pam_service, "ejabberd"}. 247 | 248 | %% 249 | %% Authentication using LDAP 250 | %% 251 | %%{auth_method, ldap}. 252 | %% 253 | %% List of LDAP servers: 254 | %%{ldap_servers, ["localhost"]}. 255 | %% 256 | %% Encryption of connection to LDAP servers: 257 | %%{ldap_encrypt, none}. 258 | %%{ldap_encrypt, tls}. 259 | %% 260 | %% Port to connect to on LDAP servers: 261 | %%{ldap_port, 389}. 262 | %%{ldap_port, 636}. 263 | %% 264 | %% LDAP manager: 265 | %%{ldap_rootdn, "dc=example,dc=com"}. 266 | %% 267 | %% Password of LDAP manager: 268 | %%{ldap_password, "******"}. 269 | %% 270 | %% Search base of LDAP directory: 271 | %%{ldap_base, "dc=example,dc=com"}. 272 | %% 273 | %% LDAP attribute that holds user ID: 274 | %%{ldap_uids, [{"mail", "%u@mail.example.org"}]}. 275 | %% 276 | %% LDAP filter: 277 | %%{ldap_filter, "(objectClass=shadowAccount)"}. 278 | 279 | %% 280 | %% Anonymous login support: 281 | %% auth_method: anonymous 282 | %% anonymous_protocol: sasl_anon | login_anon | both 283 | %% allow_multiple_connections: true | false 284 | %% 285 | %%{host_config, "public.example.org", [{auth_method, anonymous}, 286 | %% {allow_multiple_connections, false}, 287 | %% {anonymous_protocol, sasl_anon}]}. 288 | %% 289 | %% To use both anonymous and internal authentication: 290 | %% 291 | %%{host_config, "public.example.org", [{auth_method, [internal, anonymous]}]}. 292 | 293 | 294 | %%%. ============== 295 | %%%' DATABASE SETUP 296 | 297 | %% ejabberd by default uses the internal Mnesia database, 298 | %% so you do not necessarily need this section. 299 | %% This section provides configuration examples in case 300 | %% you want to use other database backends. 301 | %% Please consult the ejabberd Guide for details on database creation. 302 | 303 | %% 304 | %% MySQL server: 305 | %% 306 | %%{odbc_server, {mysql, "server", "database", "username", "password"}}. 307 | %% 308 | %% If you want to specify the port: 309 | %%{odbc_server, {mysql, "server", 1234, "database", "username", "password"}}. 310 | 311 | %% 312 | %% PostgreSQL server: 313 | %% 314 | %%{odbc_server, {pgsql, "server", "database", "username", "password"}}. 315 | %% 316 | %% If you want to specify the port: 317 | %%{odbc_server, {pgsql, "server", 1234, "database", "username", "password"}}. 318 | %% 319 | %% If you use PostgreSQL, have a large database, and need a 320 | %% faster but inexact replacement for "select count(*) from users" 321 | %% 322 | %%{pgsql_users_number_estimate, true}. 323 | 324 | %% 325 | %% ODBC compatible or MSSQL server: 326 | %% 327 | %%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}. 328 | 329 | %% 330 | %% Number of connections to open to the database for each virtual host 331 | %% 332 | %%{odbc_pool_size, 10}. 333 | 334 | %% 335 | %% Interval to make a dummy SQL request to keep the connections to the 336 | %% database alive. Specify in seconds: for example 28800 means 8 hours 337 | %% 338 | %%{odbc_keepalive_interval, undefined}. 339 | 340 | 341 | %%%. =============== 342 | %%%' TRAFFIC SHAPERS 343 | 344 | %% 345 | %% The "normal" shaper limits traffic speed to 1000 B/s 346 | %% 347 | {shaper, normal, {maxrate, 1000}}. 348 | 349 | %% 350 | %% The "fast" shaper limits traffic speed to 50000 B/s 351 | %% 352 | {shaper, fast, {maxrate, 50000}}. 353 | 354 | %% 355 | %% This option specifies the maximum number of elements in the queue 356 | %% of the FSM. Refer to the documentation for details. 357 | %% 358 | {max_fsm_queue, 1000}. 359 | 360 | 361 | %%%. ==================== 362 | %%%' ACCESS CONTROL LISTS 363 | 364 | %% 365 | %% The 'admin' ACL grants administrative privileges to XMPP accounts. 366 | %% You can put here as many accounts as you want. 367 | %% 368 | {acl, admin, {user, "ztpsadmin", "im.ztps-test.com"}}. 369 | {acl, admin, {user, "bootstrap", "im.ztps-test.com"}}. 370 | %%{acl, admin, {user, "ermine", "example.org"}}. 371 | 372 | %% 373 | %% Blocked users 374 | %% 375 | %%{acl, blocked, {user, "baduser", "example.org"}}. 376 | %%{acl, blocked, {user, "test"}}. 377 | 378 | %% 379 | %% Local users: don't modify this line. 380 | %% 381 | {acl, local, {user_regexp, ""}}. 382 | 383 | %% 384 | %% More examples of ACLs 385 | %% 386 | %%{acl, jabberorg, {server, "jabber.org"}}. 387 | %%{acl, aleksey, {user, "aleksey", "jabber.ru"}}. 388 | %%{acl, test, {user_regexp, "^test"}}. 389 | %%{acl, test, {user_glob, "test*"}}. 390 | 391 | %% 392 | %% Define specific ACLs in a virtual host. 393 | %% 394 | %%{host_config, "localhost", 395 | %% [ 396 | %% {acl, admin, {user, "bob-local", "localhost"}} 397 | %% ] 398 | %%}. 399 | 400 | 401 | %%%. ============ 402 | %%%' ACCESS RULES 403 | 404 | %% Maximum number of simultaneous sessions allowed for a single user: 405 | {access, max_user_sessions, [{10, all}]}. 406 | 407 | %% Maximum number of offline messages that users can have: 408 | {access, max_user_offline_messages, [{5000, admin}, {100, all}]}. 409 | 410 | %% This rule allows access only for local users: 411 | {access, local, [{allow, local}]}. 412 | 413 | %% Only non-blocked users can use c2s connections: 414 | {access, c2s, [{deny, blocked}, 415 | {allow, all}]}. 416 | 417 | %% For C2S connections, all users except admins use the "normal" shaper 418 | {access, c2s_shaper, [{none, admin}, 419 | {normal, all}]}. 420 | 421 | %% All S2S connections use the "fast" shaper 422 | {access, s2s_shaper, [{fast, all}]}. 423 | 424 | %% Only admins can send announcement messages: 425 | {access, announce, [{allow, admin}]}. 426 | 427 | %% Only admins can use the configuration interface: 428 | {access, configure, [{allow, admin}]}. 429 | 430 | %% Admins of this server are also admins of the MUC service: 431 | {access, muc_admin, [{allow, admin}]}. 432 | 433 | %% Only accounts of the local ejabberd server can create rooms: 434 | {access, muc_create, [{allow, all}]}. 435 | 436 | %% All users are allowed to use the MUC service: 437 | {access, muc, [{allow, all}]}. 438 | 439 | %% Only accounts on the local ejabberd server can create Pubsub nodes: 440 | {access, pubsub_createnode, [{allow, local}]}. 441 | 442 | %% In-band registration allows registration of any possible username. 443 | %% To disable in-band registration, replace 'allow' with 'deny'. 444 | {access, register, [{allow, all}]}. 445 | 446 | %% By default the frequency of account registrations from the same IP 447 | %% is limited to 1 account every 10 minutes. To disable, specify: infinity 448 | %%{registration_timeout, 600}. 449 | 450 | %% 451 | %% Define specific Access Rules in a virtual host. 452 | %% 453 | %%{host_config, "localhost", 454 | %% [ 455 | %% {access, c2s, [{allow, admin}, {deny, all}]}, 456 | %% {access, register, [{deny, all}]} 457 | %% ] 458 | %%}. 459 | 460 | 461 | %%%. ================ 462 | %%%' DEFAULT LANGUAGE 463 | 464 | %% 465 | %% language: Default language used for server messages. 466 | %% 467 | {language, "en"}. 468 | 469 | %% 470 | %% Set a different default language in a virtual host. 471 | %% 472 | %%{host_config, "localhost", 473 | %% [{language, "ru"}] 474 | %%}. 475 | 476 | 477 | %%%. ======= 478 | %%%' CAPTCHA 479 | 480 | %% 481 | %% Full path to a script that generates the image. 482 | %% 483 | %%{captcha_cmd, "/usr/lib64/ejabberd/priv/bin/captcha.sh"}. 484 | 485 | %% 486 | %% Host for the URL and port where ejabberd listens for CAPTCHA requests. 487 | %% 488 | %%{captcha_host, "example.org:5280"}. 489 | 490 | %% 491 | %% Limit CAPTCHA calls per minute for JID/IP to avoid DoS. 492 | %% 493 | %%{captcha_limit, 5}. 494 | 495 | %%%. ======= 496 | %%%' MODULES 497 | 498 | %% 499 | %% Modules enabled in all ejabberd virtual hosts. 500 | %% 501 | {modules, 502 | [ 503 | {mod_adhoc, []}, 504 | {mod_announce, [{access, announce}]}, % recommends mod_adhoc 505 | {mod_blocking,[]}, % requires mod_privacy 506 | {mod_caps, []}, 507 | {mod_configure,[]}, % requires mod_adhoc 508 | {mod_disco, []}, 509 | %%{mod_echo, [{host, "echo.localhost"}]}, 510 | {mod_irc, []}, 511 | {mod_http_bind, []}, 512 | %%{mod_http_fileserver, [ 513 | %% {docroot, "/var/www"}, 514 | %% {accesslog, "/var/log/ejabberd/access.log"} 515 | %% ]}, 516 | {mod_last, []}, 517 | {mod_muc, [ 518 | %%{host, "conference.@HOST@"}, 519 | {access, muc}, 520 | {access_create, muc_create}, 521 | {access_persistent, muc_create}, 522 | {access_admin, muc_admin} 523 | ]}, 524 | %%{mod_muc_log,[]}, 525 | {mod_offline, [{access_max_user_messages, max_user_offline_messages}]}, 526 | {mod_ping, []}, 527 | %%{mod_pres_counter,[{count, 5}, {interval, 60}]}, 528 | {mod_privacy, []}, 529 | {mod_private, []}, 530 | %%{mod_proxy65,[]}, 531 | {mod_pubsub, [ 532 | {access_createnode, pubsub_createnode}, 533 | {ignore_pep_from_offline, true}, % reduces resource comsumption, but XEP incompliant 534 | %%{ignore_pep_from_offline, false}, % XEP compliant, but increases resource comsumption 535 | {last_item_cache, false}, 536 | {plugins, ["flat", "hometree", "pep"]} % pep requires mod_caps 537 | ]}, 538 | {mod_register, [ 539 | %% 540 | %% Protect In-Band account registrations with CAPTCHA. 541 | %% 542 | %%{captcha_protected, true}, 543 | 544 | %% 545 | %% Set the minimum informational entropy for passwords. 546 | %% 547 | %%{password_strength, 32}, 548 | 549 | %% 550 | %% After successful registration, the user receives 551 | %% a message with this subject and body. 552 | %% 553 | {welcome_message, {"Welcome!", 554 | "Hi.\nWelcome to this XMPP server."}}, 555 | 556 | %% 557 | %% When a user registers, send a notification to 558 | %% these XMPP accounts. 559 | %% 560 | %%{registration_watchers, ["admin1@example.org"]}, 561 | 562 | %% 563 | %% Only clients in the server machine can register accounts 564 | %% 565 | {ip_access, [{allow, "127.0.0.0/8"}, 566 | {deny, "0.0.0.0/0"}]}, 567 | 568 | %% 569 | %% Local c2s or remote s2s users cannot register accounts 570 | %% 571 | %%{access_from, deny}, 572 | 573 | {access, register} 574 | ]}, 575 | %%{mod_register_web, [ 576 | %% 577 | %% When a user registers, send a notification to 578 | %% these XMPP accounts. 579 | %% 580 | %%{registration_watchers, ["admin1@example.org"]} 581 | %% ]}, 582 | {mod_roster, []}, 583 | %%{mod_service_log,[]}, 584 | {mod_shared_roster,[]}, 585 | {mod_stats, []}, 586 | {mod_time, []}, 587 | {mod_vcard, []}, 588 | {mod_version, []} 589 | ]}. 590 | 591 | %% 592 | %% Enable modules with custom options in a specific virtual host 593 | %% 594 | %%{host_config, "localhost", 595 | %% [{{add, modules}, 596 | %% [ 597 | %% {mod_echo, [{host, "mirror.localhost"}]} 598 | %% ] 599 | %% } 600 | %% ]}. 601 | 602 | 603 | %%%. 604 | %%%' 605 | 606 | %%% $Id$ 607 | 608 | %%% Local Variables: 609 | %%% mode: erlang 610 | %%% End: 611 | %%% vim: set filetype=erlang tabstop=8 foldmarker=%%%',%%%. foldmethod=marker: 612 | -------------------------------------------------------------------------------- /Ubuntu/conf/ejabberd.cfg: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% ejabberd configuration file 3 | %%% 4 | %%%' 5 | 6 | %%% The parameters used in this configuration file are explained in more detail 7 | %%% in the ejabberd Installation and Operation Guide. 8 | %%% Please consult the Guide in case of doubts, it is included with 9 | %%% your copy of ejabberd, and is also available online at 10 | %%% http://www.process-one.net/en/ejabberd/docs/ 11 | 12 | %%% This configuration file contains Erlang terms. 13 | %%% In case you want to understand the syntax, here are the concepts: 14 | %%% 15 | %%% - The character to comment a line is % 16 | %%% 17 | %%% - Each term ends in a dot, for example: 18 | %%% override_global. 19 | %%% 20 | %%% - A tuple has a fixed definition, its elements are 21 | %%% enclosed in {}, and separated with commas: 22 | %%% {loglevel, 4}. 23 | %%% 24 | %%% - A list can have as many elements as you want, 25 | %%% and is enclosed in [], for example: 26 | %%% [http_poll, web_admin, tls] 27 | %%% 28 | %%% - A keyword of ejabberd is a word in lowercase. 29 | %%% Strings are enclosed in "" and can contain spaces, dots, ... 30 | %%% {language, "en"}. 31 | %%% {ldap_rootdn, "dc=example,dc=com"}. 32 | %%% 33 | %%% - This term includes a tuple, a keyword, a list, and two strings: 34 | %%% {hosts, ["jabber.example.net", "im.example.com"]}. 35 | %%% 36 | 37 | 38 | %%%. ======================= 39 | %%%' OVERRIDE STORED OPTIONS 40 | 41 | %% 42 | %% Override the old values stored in the database. 43 | %% 44 | 45 | %% 46 | %% Override global options (shared by all ejabberd nodes in a cluster). 47 | %% 48 | %%override_global. 49 | 50 | %% 51 | %% Override local options (specific for this particular ejabberd node). 52 | %% 53 | %%override_local. 54 | 55 | %% 56 | %% Remove the Access Control Lists before new ones are added. 57 | %% 58 | %%override_acls. 59 | 60 | 61 | %%%. ========= 62 | %%%' DEBUGGING 63 | 64 | %% 65 | %% loglevel: Verbosity of log files generated by ejabberd. 66 | %% 0: No ejabberd log at all (not recommended) 67 | %% 1: Critical 68 | %% 2: Error 69 | %% 3: Warning 70 | %% 4: Info 71 | %% 5: Debug 72 | %% 73 | {loglevel, 5}. 74 | 75 | %% 76 | %% watchdog_admins: Only useful for developers: if an ejabberd process 77 | %% consumes a lot of memory, send live notifications to these XMPP 78 | %% accounts. 79 | %% 80 | %%{watchdog_admins, ["bob@example.com"]}. 81 | 82 | 83 | %%%. ================ 84 | %%%' SERVED HOSTNAMES 85 | 86 | %% 87 | %% hosts: Domains served by ejabberd. 88 | %% You can define one or several, for example: 89 | %% {hosts, ["example.net", "example.com", "example.org"]}. 90 | %% 91 | {hosts, ["im.ztps-test.com"]}. 92 | 93 | %% 94 | %% route_subdomains: Delegate subdomains to other XMPP servers. 95 | %% For example, if this ejabberd serves example.org and you want 96 | %% to allow communication with an XMPP server called im.example.org. 97 | %% 98 | %%{route_subdomains, s2s}. 99 | 100 | 101 | %%%. =============== 102 | %%%' LISTENING PORTS 103 | 104 | %% 105 | %% listen: The ports ejabberd will listen on, which service each is handled 106 | %% by and what options to start it with. 107 | %% 108 | {listen, 109 | [ 110 | 111 | {5222, ejabberd_c2s, [ 112 | 113 | %% 114 | %% If TLS is compiled in and you installed a SSL 115 | %% certificate, specify the full path to the 116 | %% file and uncomment this line: 117 | %% 118 | %%{certfile, "/etc/ejabberd/ejabberd.pem"}, starttls, 119 | 120 | {access, c2s}, 121 | {shaper, c2s_shaper}, 122 | {max_stanza_size, 65536} 123 | ]}, 124 | 125 | %% 126 | %% To enable the old SSL connection method on port 5223: 127 | %% 128 | %%{5223, ejabberd_c2s, [ 129 | %% {access, c2s}, 130 | %% {shaper, c2s_shaper}, 131 | %% {certfile, "/etc/ejabberd/ejabberd.pem"}, tls, 132 | %% {max_stanza_size, 65536} 133 | %% ]}, 134 | 135 | {5269, ejabberd_s2s_in, [ 136 | {shaper, s2s_shaper}, 137 | {max_stanza_size, 131072} 138 | ]}, 139 | 140 | %% 141 | %% ejabberd_service: Interact with external components (transports, ...) 142 | %% 143 | %%{8888, ejabberd_service, [ 144 | %% {access, all}, 145 | %% {shaper_rule, fast}, 146 | %% {ip, {127, 0, 0, 1}}, 147 | %% {hosts, ["icq.example.org", "sms.example.org"], 148 | %% [{password, "secret"}] 149 | %% } 150 | %% ]}, 151 | 152 | %% 153 | %% ejabberd_stun: Handles STUN Binding requests 154 | %% 155 | %%{{3478, udp}, ejabberd_stun, []}, 156 | 157 | {5280, ejabberd_http, [ 158 | %% %%{request_handlers, 159 | %% %% [ 160 | %% %% {["pub", "archive"], mod_http_fileserver} 161 | %% %% ]}, 162 | %%captcha, 163 | http_bind, 164 | http_poll, 165 | %%register, 166 | web_admin 167 | ]} 168 | 169 | ]}. 170 | 171 | %% 172 | %% s2s_use_starttls: Enable STARTTLS + Dialback for S2S connections. 173 | %% Allowed values are: false optional required required_trusted 174 | %% You must specify a certificate file. 175 | %% 176 | %%{s2s_use_starttls, optional}. 177 | 178 | %% 179 | %% s2s_certfile: Specify a certificate file. 180 | %% 181 | %%{s2s_certfile, "/etc/ejabberd/ejabberd.pem"}. 182 | 183 | %% 184 | %% domain_certfile: Specify a different certificate for each served hostname. 185 | %% 186 | %%{domain_certfile, "example.org", "/path/to/example_org.pem"}. 187 | %%{domain_certfile, "example.com", "/path/to/example_com.pem"}. 188 | 189 | %% 190 | %% S2S whitelist or blacklist 191 | %% 192 | %% Default s2s policy for undefined hosts. 193 | %% 194 | %%{s2s_default_policy, allow}. 195 | 196 | %% 197 | %% Allow or deny communication with specific servers. 198 | %% 199 | %%{{s2s_host, "goodhost.org"}, allow}. 200 | %%{{s2s_host, "badhost.org"}, deny}. 201 | 202 | %% 203 | %% Outgoing S2S options 204 | %% 205 | %% Preferred address families (which to try first) and connect timeout 206 | %% in milliseconds. 207 | %% 208 | %%{outgoing_s2s_options, [ipv4, ipv6], 10000}. 209 | 210 | 211 | %%%. ============== 212 | %%%' AUTHENTICATION 213 | 214 | %% 215 | %% auth_method: Method used to authenticate the users. 216 | %% The default method is the internal. 217 | %% If you want to use a different method, 218 | %% comment this line and enable the correct ones. 219 | %% 220 | {auth_method, internal}. 221 | %% 222 | %% Store the plain passwords or hashed for SCRAM: 223 | %%{auth_password_format, plain}. 224 | %%{auth_password_format, scram}. 225 | %% 226 | %% Define the FQDN if ejabberd doesn't detect it: 227 | %%{fqdn, "server3.example.com"}. 228 | 229 | %% 230 | %% Authentication using external script 231 | %% Make sure the script is executable by ejabberd. 232 | %% 233 | %%{auth_method, external}. 234 | %%{extauth_program, "/path/to/authentication/script"}. 235 | 236 | %% 237 | %% Authentication using ODBC 238 | %% Remember to setup a database in the next section. 239 | %% 240 | %%{auth_method, odbc}. 241 | 242 | %% 243 | %% Authentication using PAM 244 | %% 245 | %%{auth_method, pam}. 246 | %%{pam_service, "ejabberd"}. 247 | 248 | %% 249 | %% Authentication using LDAP 250 | %% 251 | %%{auth_method, ldap}. 252 | %% 253 | %% List of LDAP servers: 254 | %%{ldap_servers, ["localhost"]}. 255 | %% 256 | %% Encryption of connection to LDAP servers: 257 | %%{ldap_encrypt, none}. 258 | %%{ldap_encrypt, tls}. 259 | %% 260 | %% Port to connect to on LDAP servers: 261 | %%{ldap_port, 389}. 262 | %%{ldap_port, 636}. 263 | %% 264 | %% LDAP manager: 265 | %%{ldap_rootdn, "dc=example,dc=com"}. 266 | %% 267 | %% Password of LDAP manager: 268 | %%{ldap_password, "******"}. 269 | %% 270 | %% Search base of LDAP directory: 271 | %%{ldap_base, "dc=example,dc=com"}. 272 | %% 273 | %% LDAP attribute that holds user ID: 274 | %%{ldap_uids, [{"mail", "%u@mail.example.org"}]}. 275 | %% 276 | %% LDAP filter: 277 | %%{ldap_filter, "(objectClass=shadowAccount)"}. 278 | 279 | %% 280 | %% Anonymous login support: 281 | %% auth_method: anonymous 282 | %% anonymous_protocol: sasl_anon | login_anon | both 283 | %% allow_multiple_connections: true | false 284 | %% 285 | %%{host_config, "public.example.org", [{auth_method, anonymous}, 286 | %% {allow_multiple_connections, false}, 287 | %% {anonymous_protocol, sasl_anon}]}. 288 | %% 289 | %% To use both anonymous and internal authentication: 290 | %% 291 | %%{host_config, "public.example.org", [{auth_method, [internal, anonymous]}]}. 292 | 293 | 294 | %%%. ============== 295 | %%%' DATABASE SETUP 296 | 297 | %% ejabberd by default uses the internal Mnesia database, 298 | %% so you do not necessarily need this section. 299 | %% This section provides configuration examples in case 300 | %% you want to use other database backends. 301 | %% Please consult the ejabberd Guide for details on database creation. 302 | 303 | %% 304 | %% MySQL server: 305 | %% 306 | %%{odbc_server, {mysql, "server", "database", "username", "password"}}. 307 | %% 308 | %% If you want to specify the port: 309 | %%{odbc_server, {mysql, "server", 1234, "database", "username", "password"}}. 310 | 311 | %% 312 | %% PostgreSQL server: 313 | %% 314 | %%{odbc_server, {pgsql, "server", "database", "username", "password"}}. 315 | %% 316 | %% If you want to specify the port: 317 | %%{odbc_server, {pgsql, "server", 1234, "database", "username", "password"}}. 318 | %% 319 | %% If you use PostgreSQL, have a large database, and need a 320 | %% faster but inexact replacement for "select count(*) from users" 321 | %% 322 | %%{pgsql_users_number_estimate, true}. 323 | 324 | %% 325 | %% ODBC compatible or MSSQL server: 326 | %% 327 | %%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}. 328 | 329 | %% 330 | %% Number of connections to open to the database for each virtual host 331 | %% 332 | %%{odbc_pool_size, 10}. 333 | 334 | %% 335 | %% Interval to make a dummy SQL request to keep the connections to the 336 | %% database alive. Specify in seconds: for example 28800 means 8 hours 337 | %% 338 | %%{odbc_keepalive_interval, undefined}. 339 | 340 | 341 | %%%. =============== 342 | %%%' TRAFFIC SHAPERS 343 | 344 | %% 345 | %% The "normal" shaper limits traffic speed to 1000 B/s 346 | %% 347 | {shaper, normal, {maxrate, 1000}}. 348 | 349 | %% 350 | %% The "fast" shaper limits traffic speed to 50000 B/s 351 | %% 352 | {shaper, fast, {maxrate, 50000}}. 353 | 354 | %% 355 | %% This option specifies the maximum number of elements in the queue 356 | %% of the FSM. Refer to the documentation for details. 357 | %% 358 | {max_fsm_queue, 1000}. 359 | 360 | 361 | %%%. ==================== 362 | %%%' ACCESS CONTROL LISTS 363 | 364 | %% 365 | %% The 'admin' ACL grants administrative privileges to XMPP accounts. 366 | %% You can put here as many accounts as you want. 367 | %% 368 | {acl, admin, {user, "ztpsadmin", "im.ztps-test.com"}}. 369 | {acl, admin, {user, "bootstrap", "im.ztps-test.com"}}. 370 | %%{acl, admin, {user, "ermine", "example.org"}}. 371 | 372 | %% 373 | %% Blocked users 374 | %% 375 | %%{acl, blocked, {user, "baduser", "example.org"}}. 376 | %%{acl, blocked, {user, "test"}}. 377 | 378 | %% 379 | %% Local users: don't modify this line. 380 | %% 381 | {acl, local, {user_regexp, ""}}. 382 | 383 | %% 384 | %% More examples of ACLs 385 | %% 386 | %%{acl, jabberorg, {server, "jabber.org"}}. 387 | %%{acl, aleksey, {user, "aleksey", "jabber.ru"}}. 388 | %%{acl, test, {user_regexp, "^test"}}. 389 | %%{acl, test, {user_glob, "test*"}}. 390 | 391 | %% 392 | %% Define specific ACLs in a virtual host. 393 | %% 394 | %%{host_config, "localhost", 395 | %% [ 396 | %% {acl, admin, {user, "bob-local", "localhost"}} 397 | %% ] 398 | %%}. 399 | 400 | 401 | %%%. ============ 402 | %%%' ACCESS RULES 403 | 404 | %% Maximum number of simultaneous sessions allowed for a single user: 405 | {access, max_user_sessions, [{10, all}]}. 406 | 407 | %% Maximum number of offline messages that users can have: 408 | {access, max_user_offline_messages, [{5000, admin}, {100, all}]}. 409 | 410 | %% This rule allows access only for local users: 411 | {access, local, [{allow, local}]}. 412 | 413 | %% Only non-blocked users can use c2s connections: 414 | {access, c2s, [{deny, blocked}, 415 | {allow, all}]}. 416 | 417 | %% For C2S connections, all users except admins use the "normal" shaper 418 | {access, c2s_shaper, [{none, admin}, 419 | {normal, all}]}. 420 | 421 | %% All S2S connections use the "fast" shaper 422 | {access, s2s_shaper, [{fast, all}]}. 423 | 424 | %% Only admins can send announcement messages: 425 | {access, announce, [{allow, admin}]}. 426 | 427 | %% Only admins can use the configuration interface: 428 | {access, configure, [{allow, admin}]}. 429 | 430 | %% Admins of this server are also admins of the MUC service: 431 | {access, muc_admin, [{allow, admin}]}. 432 | 433 | %% Only accounts of the local ejabberd server can create rooms: 434 | {access, muc_create, [{allow, all}]}. 435 | 436 | %% All users are allowed to use the MUC service: 437 | {access, muc, [{allow, all}]}. 438 | 439 | %% Only accounts on the local ejabberd server can create Pubsub nodes: 440 | {access, pubsub_createnode, [{allow, local}]}. 441 | 442 | %% In-band registration allows registration of any possible username. 443 | %% To disable in-band registration, replace 'allow' with 'deny'. 444 | {access, register, [{allow, all}]}. 445 | 446 | %% By default the frequency of account registrations from the same IP 447 | %% is limited to 1 account every 10 minutes. To disable, specify: infinity 448 | %%{registration_timeout, 600}. 449 | 450 | %% 451 | %% Define specific Access Rules in a virtual host. 452 | %% 453 | %%{host_config, "localhost", 454 | %% [ 455 | %% {access, c2s, [{allow, admin}, {deny, all}]}, 456 | %% {access, register, [{deny, all}]} 457 | %% ] 458 | %%}. 459 | 460 | 461 | %%%. ================ 462 | %%%' DEFAULT LANGUAGE 463 | 464 | %% 465 | %% language: Default language used for server messages. 466 | %% 467 | {language, "en"}. 468 | 469 | %% 470 | %% Set a different default language in a virtual host. 471 | %% 472 | %%{host_config, "localhost", 473 | %% [{language, "ru"}] 474 | %%}. 475 | 476 | 477 | %%%. ======= 478 | %%%' CAPTCHA 479 | 480 | %% 481 | %% Full path to a script that generates the image. 482 | %% 483 | %%{captcha_cmd, "/usr/lib64/ejabberd/priv/bin/captcha.sh"}. 484 | 485 | %% 486 | %% Host for the URL and port where ejabberd listens for CAPTCHA requests. 487 | %% 488 | %%{captcha_host, "example.org:5280"}. 489 | 490 | %% 491 | %% Limit CAPTCHA calls per minute for JID/IP to avoid DoS. 492 | %% 493 | %%{captcha_limit, 5}. 494 | 495 | %%%. ======= 496 | %%%' MODULES 497 | 498 | %% 499 | %% Modules enabled in all ejabberd virtual hosts. 500 | %% 501 | {modules, 502 | [ 503 | {mod_adhoc, []}, 504 | {mod_announce, [{access, announce}]}, % recommends mod_adhoc 505 | {mod_blocking,[]}, % requires mod_privacy 506 | {mod_caps, []}, 507 | {mod_configure,[]}, % requires mod_adhoc 508 | {mod_disco, []}, 509 | %%{mod_echo, [{host, "echo.localhost"}]}, 510 | {mod_irc, []}, 511 | {mod_http_bind, []}, 512 | %%{mod_http_fileserver, [ 513 | %% {docroot, "/var/www"}, 514 | %% {accesslog, "/var/log/ejabberd/access.log"} 515 | %% ]}, 516 | {mod_last, []}, 517 | {mod_muc, [ 518 | %%{host, "conference.@HOST@"}, 519 | {access, muc}, 520 | {access_create, muc_create}, 521 | {access_persistent, muc_create}, 522 | {access_admin, muc_admin} 523 | ]}, 524 | %%{mod_muc_log,[]}, 525 | {mod_offline, [{access_max_user_messages, max_user_offline_messages}]}, 526 | {mod_ping, []}, 527 | %%{mod_pres_counter,[{count, 5}, {interval, 60}]}, 528 | {mod_privacy, []}, 529 | {mod_private, []}, 530 | %%{mod_proxy65,[]}, 531 | {mod_pubsub, [ 532 | {access_createnode, pubsub_createnode}, 533 | {ignore_pep_from_offline, true}, % reduces resource comsumption, but XEP incompliant 534 | %%{ignore_pep_from_offline, false}, % XEP compliant, but increases resource comsumption 535 | {last_item_cache, false}, 536 | {plugins, ["flat", "hometree", "pep"]} % pep requires mod_caps 537 | ]}, 538 | {mod_register, [ 539 | %% 540 | %% Protect In-Band account registrations with CAPTCHA. 541 | %% 542 | %%{captcha_protected, true}, 543 | 544 | %% 545 | %% Set the minimum informational entropy for passwords. 546 | %% 547 | %%{password_strength, 32}, 548 | 549 | %% 550 | %% After successful registration, the user receives 551 | %% a message with this subject and body. 552 | %% 553 | {welcome_message, {"Welcome!", 554 | "Hi.\nWelcome to this XMPP server."}}, 555 | 556 | %% 557 | %% When a user registers, send a notification to 558 | %% these XMPP accounts. 559 | %% 560 | %%{registration_watchers, ["admin1@example.org"]}, 561 | 562 | %% 563 | %% Only clients in the server machine can register accounts 564 | %% 565 | {ip_access, [{allow, "127.0.0.0/8"}, 566 | {deny, "0.0.0.0/0"}]}, 567 | 568 | %% 569 | %% Local c2s or remote s2s users cannot register accounts 570 | %% 571 | %%{access_from, deny}, 572 | 573 | {access, register} 574 | ]}, 575 | %%{mod_register_web, [ 576 | %% 577 | %% When a user registers, send a notification to 578 | %% these XMPP accounts. 579 | %% 580 | %%{registration_watchers, ["admin1@example.org"]} 581 | %% ]}, 582 | {mod_roster, []}, 583 | %%{mod_service_log,[]}, 584 | {mod_shared_roster,[]}, 585 | {mod_stats, []}, 586 | {mod_time, []}, 587 | {mod_vcard, []}, 588 | {mod_version, []} 589 | ]}. 590 | 591 | %% 592 | %% Enable modules with custom options in a specific virtual host 593 | %% 594 | %%{host_config, "localhost", 595 | %% [{{add, modules}, 596 | %% [ 597 | %% {mod_echo, [{host, "mirror.localhost"}]} 598 | %% ] 599 | %% } 600 | %% ]}. 601 | 602 | 603 | %%%. 604 | %%%' 605 | 606 | %%% $Id$ 607 | 608 | %%% Local Variables: 609 | %%% mode: erlang 610 | %%% End: 611 | %%% vim: set filetype=erlang tabstop=8 foldmarker=%%%',%%%. foldmethod=marker: 612 | -------------------------------------------------------------------------------- /lib/eosplusvnets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ############################################## 4 | # Library for creating ZTPServer-related Demos 5 | # Author: eosplus-dev@arista.com 6 | # Date: 20150113 7 | ############################################## 8 | 9 | import sys 10 | import os 11 | import re 12 | import platform 13 | import argparse 14 | import subprocess 15 | import datetime 16 | import urllib 17 | import zipfile 18 | import getpass 19 | 20 | 21 | packerURL = "https://releases.hashicorp.com/packer/1.1.3" 22 | packerVersion = "1.1.3" 23 | 24 | class bcolors: 25 | HEADER = '\033[95m' 26 | OKBLUE = '\033[94m' 27 | OKGREEN = '\033[92m' 28 | WARNING = '\033[93m' 29 | FAIL = '\033[91m' 30 | ENDC = '\033[0m' 31 | BOLD = '\033[1m' 32 | UNDERLINE = '\033[4m' 33 | 34 | def getHostOS(): 35 | return platform.system().lower() 36 | 37 | def getHostArch(): 38 | is_64bits = sys.maxsize > 2**32 39 | return 64 if is_64bits else 32 40 | 41 | def which(program): 42 | def is_exe(fpath): 43 | return os.path.isfile(fpath) and os.access(fpath, os.X_OK) 44 | 45 | fpath, fname = os.path.split(program) 46 | if fpath: 47 | if is_exe(program): 48 | return program 49 | else: 50 | for path in os.environ["PATH"].split(os.pathsep): 51 | path = path.strip('"') 52 | exe_file = os.path.join(path, program) 53 | if is_exe(exe_file): 54 | return exe_file 55 | 56 | return False 57 | 58 | def find(path, name): 59 | print "Searching %s for %s..." % (path, name) 60 | # Look recursively through OS for files 61 | for root, dirs, files in os.walk(path): 62 | #print files 63 | if name in files: 64 | print "Found file here:%s" % root 65 | return root 66 | if name in dirs: 67 | print "Found file here:%s" % root 68 | return os.path.join(root, name) 69 | 70 | # File wasn't found, return false 71 | return False 72 | 73 | def getUnzipped(url, dest, fn): 74 | name = os.path.join(dest, fn) 75 | try: 76 | if find(dest, fn.split(".zip")[0]): 77 | print "%s already exists, no need to download again." % fn.split(".zip")[0] 78 | else: 79 | print "Downloading Packer binaries to %s" % name 80 | print "This may take a few minutes (~85MB)..." 81 | name, hdrs = urllib.urlretrieve(url, name) 82 | print "Download successful!" 83 | except IOError, e: 84 | print "Can't retrieve %r to %r: %s" % (url, name, e) 85 | raise 86 | 87 | try: 88 | print "Unzipping %s..." % name 89 | with zipfile.ZipFile(name, "r") as z: 90 | bin = os.path.join(dest, "packer-bin") 91 | z.extractall(bin) 92 | except zipfile.error, e: 93 | print "Bad zipfile (from %r): %s" % (url, e) 94 | raise 95 | print "Unzipped successfully to %s" % bin 96 | return bin 97 | 98 | def installPacker(hostOS, hostArch): 99 | if hostArch == 64: 100 | arch = "amd64" 101 | else: 102 | arch = "386" 103 | 104 | url = "%s/packer_%s_%s_%s.zip" % (packerURL, packerVersion, hostOS, arch) 105 | 106 | installPath = os.path.expanduser('~') 107 | packerZipDir = getUnzipped(url, installPath, "packer-bin.zip") 108 | packerDir = os.path.join(installPath, "packer-bin") 109 | 110 | # Make all Packer binaries executable 111 | for file in os.listdir(packerDir): 112 | file = os.path.join(packerDir, file) 113 | os.chmod(file, 0o777) 114 | 115 | # Add packer-bin to path 116 | os.environ["PATH"] += os.pathsep + packerDir 117 | print "Updated path to be:%s" % os.environ["PATH"] 118 | print "Packer installed!" 119 | return os.path.join(packerDir, "packer") 120 | 121 | def getActiveNets(cmd, regex): 122 | # Get existing networks and return array of numbers 123 | try: 124 | ifconfig = subprocess.check_output(cmd) 125 | return re.findall(r"%s" % regex, ifconfig) 126 | except OSError as e: 127 | if e.errno == os.errno.ENOENT: 128 | print "vboxnet creation failed. Check output above" 129 | raise 130 | else: 131 | print "Something else went wrong" 132 | raise 133 | 134 | def createVBoxNets(hostOS, hostArch, libDir): 135 | print "Creating virtual networks for Virtual Box" 136 | 137 | if hostOS == "darwin": 138 | # Open VirtualBox App 139 | print "Opening VirtualBox application..." 140 | cmd = ["open", "-a", "VirtualBox"] 141 | process = subprocess.Popen(cmd) 142 | 143 | #Get list of current networks 144 | cmd = ["ifconfig", "-a"] 145 | regex = "vboxnet(\d+)" 146 | activeNets = getActiveNets(cmd, regex) 147 | 148 | print "\nAnalyzing Host-Only Networks..." 149 | 150 | # Create vmnets 151 | vmnets = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 152 | if len(activeNets) < len(vmnets): 153 | if len(activeNets) > 0: 154 | print "Existing Host-Only networks found:" 155 | for n in activeNets: 156 | print " - %s" % n 157 | else: 158 | print "No existing Host-Only networks found." 159 | 160 | numCreate = len(vmnets) - len(activeNets) 161 | for i in range(0, numCreate): 162 | try: 163 | cmd = "%s/vboxmanage" % libDir 164 | subprocess.call([cmd, "hostonlyif", "create"]) 165 | except OSError as e: 166 | if e.errno == os.errno.ENOENT: 167 | print "vboxnet creation failed. Check output above" 168 | raise 169 | else: 170 | print "Something else went wrong" 171 | raise 172 | else: 173 | print "Enough existing virtual networks exist. Let's just reconfigure them." 174 | 175 | try: 176 | for net in vmnets: 177 | 178 | print "Creating/modifying vboxnet%s" % net 179 | network = int(net) + 128 180 | print " - Assigning vboxnet%s to 172.16.%s.1/24" % (net, network) 181 | 182 | cmd = "%s/vboxmanage" % libDir 183 | vboxnet = "vboxnet%s" % net 184 | ip = "172.16.%s.1" % network 185 | subprocess.call([cmd, "hostonlyif", "ipconfig", vboxnet, 186 | "-ip", ip, "-netmask", "255.255.255.0"]) 187 | except OSError as e: 188 | if e.errno == os.errno.ENOENT: 189 | print "vboxnet creation failed. Check output above" 190 | raise 191 | else: 192 | print "Something else went wrong" 193 | raise 194 | 195 | # Remove any DHCP Servers from virtual networks 196 | try: 197 | cmd = "%s/vboxmanage" % libDir 198 | dhcpList = subprocess.check_output([cmd, "list", "dhcpservers"]) 199 | regex = "NetworkName:\s+(\S+)" 200 | hostOnlyDHCPSrvs = re.findall(r"%s" % regex, dhcpList) 201 | 202 | print "Disabling DHCP Servers" 203 | for srv in hostOnlyDHCPSrvs: 204 | print "Disabling HostOnlyIf DHCP Server %s" % srv 205 | subprocess.call([cmd, "dhcpserver", "remove", "--netname", srv]) 206 | 207 | return True 208 | 209 | except OSError as e: 210 | if e.errno == os.errno.ENOENT: 211 | print "vboxnet creation failed. Check output above" 212 | raise 213 | else: 214 | print "Something else went wrong" 215 | raise 216 | 217 | elif hostOS == "windows": 218 | # Open VirtualBox App 219 | print "Opening VirtualBox application..." 220 | cmd = ["%s/VirtualBox.exe" % libDir] 221 | process = subprocess.Popen(cmd) 222 | 223 | #Get list of current networks 224 | cmd = ["ipconfig"] 225 | regex = "Ethernet.*(VirtualBox Host-Only.*):" 226 | activeNets = getActiveNets(cmd, regex) 227 | 228 | print "\nAnalyzing Host-Only Networks..." 229 | 230 | # Create vmnets 231 | vmnets = ("", " #2", " #3", " #4", " #5", " #6", " #7", " #8", " #9", " #10") 232 | if len(activeNets) < len(vmnets): 233 | if len(activeNets) > 0: 234 | print "Existing Host-Only networks found:" 235 | for n in activeNets: 236 | print " - %s" % n 237 | else: 238 | print "No existing Host-Only networks found." 239 | 240 | numCreate = len(vmnets) - len(activeNets) 241 | print "Creating %s new Host-Only Networks" % numCreate 242 | for i in range(0, numCreate): 243 | try: 244 | cmd = "%s/vboxmanage" % libDir 245 | subprocess.call([cmd, "hostonlyif", "create"]) 246 | except OSError as e: 247 | if e.errno == os.errno.ENOENT: 248 | print "vboxnet creation failed. Check output above" 249 | raise 250 | else: 251 | print "Something else went wrong" 252 | raise 253 | else: 254 | print "Enough existing virtual networks exist. Let's just reconfigure them." 255 | print "Existing Host-Only networks found:" 256 | for n in activeNets: 257 | print " - %s" % n 258 | 259 | try: 260 | network = 128 261 | for net in vmnets: 262 | 263 | print "Modifying VirtualBox Host-Only Ethernet Adapter%s" % net 264 | print " - Assigning VirtualBox Host-Only Ethernet Adapter%s to 172.16.%s.1/24\n" % (net, network) 265 | 266 | cmd = "%s/vboxmanage" % libDir 267 | vboxnet = "VirtualBox Host-Only Ethernet Adapter%s" % net 268 | ip = "172.16.%s.1" % network 269 | subprocess.call([cmd, "hostonlyif", "ipconfig", vboxnet, 270 | "-ip", ip, "-netmask", "255.255.255.0"]) 271 | network += 1 272 | 273 | except OSError as e: 274 | if e.errno == os.errno.ENOENT: 275 | print "vboxnet creation failed. Check output above" 276 | raise 277 | else: 278 | print "Something else went wrong" 279 | raise 280 | 281 | # Remove any DHCP Servers from virtual networks 282 | try: 283 | cmd = "%s/vboxmanage" % libDir 284 | dhcpList = subprocess.check_output([cmd, "list", "dhcpservers"]) 285 | regex = "NetworkName:\s+(\S+.*)" 286 | hostOnlyDHCPSrvs = re.findall(r"%s" % regex, dhcpList) 287 | 288 | print "Disabling DHCP Servers" 289 | for srv in hostOnlyDHCPSrvs: 290 | print " - Disabling DHCP Server %s" % srv 291 | subprocess.call([cmd, "dhcpserver", "remove", "--netname", "%s" % srv], shell=True) 292 | except OSError as e: 293 | if e.errno == os.errno.ENOENT: 294 | print "vboxnet creation failed. Check output above" 295 | raise 296 | else: 297 | print "Something else went wrong" 298 | raise 299 | return True 300 | 301 | def createVmNets(hostOS, hostArch, libDir): 302 | print "Creating virtual networks for VMware" 303 | 304 | if hostOS == "darwin": 305 | # Open VMware Fusion App 306 | cmd = ["open", "-a", "VMware Fusion"] 307 | process = subprocess.Popen(cmd) 308 | 309 | #Get list of current networks 310 | cmd = ["ifconfig"] 311 | regex = "vmnet(\d+)" 312 | activeNets = getActiveNets(cmd, regex) 313 | 314 | print "\nAnalyzing Host-Only Networks..." 315 | 316 | # Create/modify vmnets 317 | vmnets = (2, 3, 4, 5, 6, 7, 9, 10, 11) 318 | try: 319 | if len(activeNets) > 0: 320 | print "Existing vmnets found:" 321 | for n in activeNets: 322 | print " - VMnet%s" % n 323 | else: 324 | print "No existing vmnets found." 325 | 326 | print "Creating/modifying vmnets" 327 | for net in vmnets: 328 | 329 | print "Creating/modifying vmnet%s" % net 330 | print "---------------------------" 331 | 332 | network = int(net) + 128 333 | netcfgCmd = r"%s/vmnet-cfgcli" % libDir 334 | cfgCmd = r"%s/vmnet-cli" % libDir 335 | dhcpCmd = "VNET_%s_DHCP" % net 336 | subnetCmd = "VNET_%s_HOSTONLY_SUBNET" % net 337 | subnet = "172.16.%s.0" % network 338 | netmaskCmd = "VNET_%s_HOSTONLY_NETMASK" % net 339 | virtualCmd = "VNET_%s_VIRTUAL_ADAPTER" % net 340 | subprocess.call(["sudo", netcfgCmd, "vnetcfgadd", dhcpCmd, "no"]) 341 | subprocess.call(["sudo", netcfgCmd, "vnetcfgadd", subnetCmd, subnet]) 342 | subprocess.call(["sudo", netcfgCmd, "vnetcfgadd", netmaskCmd, "255.255.255.0"]) 343 | subprocess.call(["sudo", netcfgCmd, "vnetcfgadd", virtualCmd, "yes"]) 344 | 345 | # Configure and restart to take effect 346 | print "Committing vmware network services" 347 | print "----------------------------------" 348 | subprocess.call(["sudo", cfgCmd, "--configure"]) 349 | 350 | print "Stopping vmware network services" 351 | print "--------------------------------" 352 | subprocess.call(["sudo", cfgCmd, "--stop"]) 353 | 354 | print "Starting vmware network services" 355 | print "--------------------------------" 356 | subprocess.call(["sudo", cfgCmd, "--start"]) 357 | 358 | print "VMNets Installed!" 359 | 360 | except OSError as e: 361 | if e.errno == os.errno.ENOENT: 362 | print "vmnet creation failed. Check output above" 363 | raise 364 | else: 365 | print "Something else went wrong" 366 | raise 367 | 368 | return True 369 | 370 | elif hostOS == "windows": 371 | # Open VMware Fusion App 372 | cmd = ["%s/vmware.exe" % libDir] 373 | process = subprocess.Popen(cmd) 374 | 375 | #Get list of current networks 376 | cmd = ["ipconfig"] 377 | regex = "VMnet(\d+)" 378 | activeNets = getActiveNets(cmd, regex) 379 | 380 | print "\nAnalyzing Host-Only Networks..." 381 | 382 | # Create/modify vmnets 383 | vmnets = ["2", "3", "4", "5", "6", "7", "9", "10", "11"] 384 | 385 | try: 386 | if len(activeNets) > 0: 387 | print "Existing vmnets found:" 388 | for n in activeNets: 389 | print " - VMnet%s" % n 390 | else: 391 | print "No existing vmnets found." 392 | 393 | # Trim vmnets 394 | createNets = [x for x in vmnets if x not in activeNets] 395 | 396 | netcfgCmd = r"%s/vnetlib.exe" % libDir 397 | print netcfgCmd 398 | 399 | # Stop Workstation services - nat dhcp 400 | print "Stopping VMware Workstation NAT service" 401 | rc = subprocess.call([netcfgCmd, "--", "stop", "nat"]) 402 | print "Stopping VMware Workstation DHCP service" 403 | rc = subprocess.call([netcfgCmd, "--", "stop", "dhcp"]) 404 | 405 | # create networks that dont already exist 406 | for net in createNets: 407 | netName = "vmnet%s" % net 408 | print " - Creating new virtual network %s" % netName 409 | rc = subprocess.call([netcfgCmd, "--", "add", 410 | "adapter", netName]) 411 | rc = subprocess.call([netcfgCmd, "--", "update", 412 | "adapter", netName]) 413 | 414 | # Configure ALL of the networks in vmnets list 415 | for net in vmnets: 416 | network = 128 + int(net) 417 | netName = "vmnet%s" % net 418 | mask = "255.255.255.0" 419 | addr = "172.16.%s.0" % network 420 | print "Modifying virtual network %s" % netName 421 | print " - setting netmask to %s" % mask 422 | rc = subprocess.call([netcfgCmd, "--", "set", "vnet", 423 | netName, "mask", mask]) 424 | print " - setting address to %s" % addr 425 | rc = subprocess.call([netcfgCmd, "--", "set", "vnet", 426 | netName, "addr", addr]) 427 | print " - disabling DHCP server on vmnet%s" % net 428 | rc = subprocess.call([netcfgCmd, "--", "remove", 429 | "dhcp", netName]) 430 | print " - disabling NAT on vmnet%s" % net 431 | rc = subprocess.call([netcfgCmd, "--", "remove", 432 | "nat", netName]) 433 | print " - saving changes for vmnet%s" % net 434 | rc = subprocess.call([netcfgCmd, "--", "update", 435 | "dhcp", netName]) 436 | rc = subprocess.call([netcfgCmd, "--", "update", 437 | "nat", netName]) 438 | rc = subprocess.call([netcfgCmd, "--", "update", 439 | "adapter", netName]) 440 | 441 | # Start DHCP and NAT 442 | print "Starting VMware Workstation NAT service" 443 | rc = subprocess.call([netcfgCmd, "--", "start", "nat"]) 444 | print "Starting VMware Workstation DHCP service" 445 | rc = subprocess.call([netcfgCmd, "--", "start", "dhcp"]) 446 | 447 | print "VMNets Installed!" 448 | except OSError as e: 449 | if e.errno == os.errno.ENOENT: 450 | print "vmnet creation failed. Check output above" 451 | raise 452 | else: 453 | print "Something else went wrong" 454 | raise 455 | 456 | return True 457 | --------------------------------------------------------------------------------