パスワード文字列にすると 0⇔O とか 1⇔l⇔I が紛らわしいので、その辺は取り除いてある。
# cat /dev/urandom | tr -c -d '[:alnum:]' | tr -d 'O0lI1' | head -c 16 | awk '{print}'からくりとしては、/dev/urandomからランダムなバイト列を読み出して、英数字(alnum)のみをフィルタリング、"O0lI1"を取り除いて、先頭16文字だけ表示している。
# cat /dev/urandom | tr -c -d '[:alnum:]' | tr -d 'O0lI1' | head -c 16 | awk '{print}'からくりとしては、/dev/urandomからランダムなバイト列を読み出して、英数字(alnum)のみをフィルタリング、"O0lI1"を取り除いて、先頭16文字だけ表示している。
-- SET ROOT PASSWORD -- UPDATE mysql.user SET Password=PASSWORD('[パスワード文字列]') WHERE User='root';
-- REMOVE ANONYMOUS USERS -- DELETE FROM mysql.user WHERE User='';
-- REMOVE REMOTE ROOT -- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
-- REMOVE TEST DATABASE -- DROP DATABASE test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
-- RELOAD PRIVILEGE TABLES -- FLUSH PRIVILEGES;
PS C:\VHD> New-VM -Name Chef-Serv Name State CPUUsage(%) MemoryAssigned(M) Uptime Status ---- ----- ----------- ----------------- ------ ------ Chef-Serv Off 0 0 00:00:00 正常稼働中○仮想マシンのメモリ量を設定する。
PS C:\VHD> Set-VMMemory -VMName Chef-Serv -StartupBytes 2048MB PS C:\VHD> Get-VMMemory -VMName Chef-Serv VMName DynamicMemoryEnabled Minimum(M) Startup(M) Maximum(M) ------ -------------------- ---------- ---------- ---------- Chef-Serv False 512 2048 1048576
PS C:\VHD> New-VHD -Path C:\VHD\Chef-Serv.vhdx -Dynamic -BlockSizeBytes 1MB -SizeBytes 16GB ComputerName : TESTPC01 Path : C:\VHD\Chef-Serv.vhdx VhdFormat : VHDX VhdType : Dynamic FileSize : 4194304 Size : 17179869184 MinimumSize : LogicalSectorSize : 512 PhysicalSectorSize : 4096 BlockSize : 1048576 ParentPath : FragmentationPercentage : 0 Alignment : 1 Attached : False DiskNumber : IsDeleted : False Number :
PS C:\VHD> Add-VMHardDiskDrive -VMName Chef-Serv -ControllerType IDE -ControllerLocation 0 -Path C:\VHD\Chef-Serv.vhdx PS C:\VHD> Get-VMHardDiskDrive -VMName Chef-Serv VMName ControllerType ControllerNumber ControllerLocation DiskNumber Path ------ -------------- ---------------- ------------------ ---------- ---- Chef-Serv IDE 0 0 C:\VHD\Chef-Serv.vhdx
PS C:\VHD> Get-VMSwitch Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ 外部接続スイッチ(有線LAN経由) External Intel(R) 82579LM Gigabit Network Connection 外部接続スイッチ(WiMAX経由) External Remote NDIS based Internet Sharing Device 内部接続スイッチ Internal 外部接続スイッチ(無線LAN経由) External Intel(R) Centrino(R) Advanced-N 6205 PS C:\VHD> Add-VMNetworkAdapter -VMName Chef-Serv -SwitchName "外部接続スイッチ(WiMAX経由)" PS C:\VHD> Get-VMNetworkAdapter -VMName Chef-Serv Name IsManagementOs VMName SwitchName MacAddress Status IPAddresses ---- -------------- ------ ---------- ---------- ------ ----------- ネットワーク アダプター False Chef-Serv 外部接続スイッチ(WiMAX経由) 000000000000 {}
PS C:\VHD> Set-VMDvdDrive -VMName Chef-Serv -Path C:\TEMP\CentOS-6.4-x86_64-minimal.iso PS C:\VHD> Get-VMDvdDrive -VMName Chef-Serv VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path ------ -------------- ---------------- ------------------ ------------ ---- Chef-Serv IDE 1 0 ISO C:\TEMP\CentOS-6.4-x86_64-minimal.iso
PS C:\VHD> Start-VM -VMName Chef-Serv PS C:\VHD> vmconnect localhost Chef-Serv
# yum -y update
# ifconfig -a | grep eth1 | awk '{print "HWADDR="$5;} > /etc/sysconfig/network-scripts/ifcfg-eth1 # vi /etc/sysconfig/network-scripts/ifcfg-eth1 HWADDR=00:15:5D:00:6A:1B ONBOOT=yes TYPE=Ethernet IPADDR=192.168.101.11 NETMASK=255.255.255.0 # vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=CHEFSERV.local # vi /etc/hosts 192.168.101.11 CHEFSREV CHEFSERV.local # ifconfig -a
# service iptables stop # chkconfig iptables off # service ip6tables stop # chkconfig ip6tables off # shutdown -r now
# curl -O -L https://opscode-omnitruck-release.s3.amazonaws.com/el/6/x86_64/chef-server-11.0.6-1.el6.x86_64.rpm % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 169M 100 169M 0 0 444k 0 0:06:30 0:06:30 --:--:-- 480k # file chef-server-11.0.6-1.el6.x86_64.rpm chef-server-11.0.6-1.el6.x86_64.rpm: RPM v3.0 bin i386/x86_64 chef-server-11.0.6-1.el6 # ls -l chef-server-11.0.6-1.el6.x86_64.rpm -rw-r--r--. 1 root root 177967164 3月 25 16:12 2013 chef-server-11.0.6-1.el6.x86_64.rpm
# rpm -ivh chef-server-11.0.6-1.el6.x86_64.rpm 警告: chef-server-11.0.6-1.el6.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY 準備中... ########################################### [100%] 1:chef-server ########################################### [100%] Thank you for installing Chef Server! The next step in the install process is to run: sudo chef-server-ctl reconfigure
# chef-server-ctl reconfigure # chef-server-ctl test
# grep web_ui_admin /opt/chef-server/embedded/cookbooks/chef-server/attributes/default.rb default['chef_server']['chef-server-webui']['web_ui_admin_user_name'] = "admin" default['chef_server']['chef-server-webui']['web_ui_admin_default_password'] = "p@ssw0rd1"
# curl -O -L https://opscode-omnitruck-release.s3.amazonaws.com/el/6/x86_64/chef-11.4.0-1.el6.x86_64.rpm # rpm -ivh chef-11.4.0-1.el6.x86_64.rpm 警告: chef-11.4.0-1.el6.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY 準備中... ########################################### [100%] 1:chef ########################################### [100%] Thank you for installing Chef!
# yum install git # git clone https://github.com/opscode/chef-repo.git chef-repo Initialized empty Git repository in /root/chef-repo/.git/ remote: Counting objects: 202, done. remote: Compressing objects: 100% (120/120), done. remote: Total 202 (delta 73), reused 162 (delta 49) Receiving objects: 100% (202/202), 34.27 KiB, done. Resolving deltas: 100% (73/73), done. # cd chef-repo # ls -al drwxr-xr-x. 9 root root 4096 3月 25 16:47 2013 . dr-xr-x---. 6 root root 4096 3月 25 16:46 2013 .. drwxr-xr-x. 8 root root 4096 3月 25 16:47 2013 .git -rw-r--r--. 1 root root 18 3月 25 16:47 2013 .gitignore -rw-r--r--. 1 root root 10850 3月 25 16:47 2013 LICENSE -rw-r--r--. 1 root root 3521 3月 25 16:47 2013 README.md -rw-r--r--. 1 root root 2171 3月 25 16:47 2013 Rakefile drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 certificates -rw-r--r--. 1 root root 156 3月 25 16:47 2013 chefignore drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 config drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 cookbooks drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 data_bags drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 environments drwxr-xr-x. 2 root root 4096 3月 25 16:47 2013 roles
# mkdir .chef # cd .chef # scp -p chefserv:/etc/chef-server/admin.pem ./ # scp -p chefserv:/etc/chef-server/chef-validator.pem ./ # ls -al drwxr-xr-x. 2 root root 4096 3月 25 16:51 2013 . drwxr-xr-x. 10 root root 4096 3月 25 16:48 2013 .. -rw-------. 1 root root 1679 3月 25 16:19 2013 admin.pem -rw-------. 1 root root 1679 3月 25 16:19 2013 chef-validator.pem
# knife configure WARNING: No knife configuration file found Where should I put the config file? [/root/.chef/knife.rb] /root/chef-repo/.chef/knife.rb Please enter the chef server URL: [http://CHEFSERV:4000] https://chefserv:443 Please enter an existing username or clientname for the API: [root] admin Please enter the validation clientname: [chef-validator] Please enter the location of the validation key: [/etc/chef/validation.pem] Please enter the path to a chef repository (or leave blank): /root/chef-repo ***** You must place your client key in: /root/chef-repo/.chef/admin.pem Before running commands with Knife! ***** You must place your validation key in: /etc/chef/validation.pem Before generating instance data with Knife! ***** Configuration file written to /root/chef-repo/.chef/knife.rb
# cd ~/chef-repo # knife bootstrap zabbixsv.local Bootstrapping Chef on zabbixsv.local Failed to authenticate root - trying password auth Enter your password: zabbixsv.local Downloading Chef 11.4.0 for el... zabbixsv.local Installing Chef 11.4.0 zabbixsv.local 警告: /tmp/tmp.NxRNG2Nq/chef-11.4.0.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY zabbixsv.local 準備中... zabbixsv.local ######################################## (100%) zabbixsv.local ########################################### [100%] zabbixsv.local 1:chef zabbixsv.local ########################################### [100%] zabbixsv.local Thank you for installing Chef! zabbixsv.local Starting Chef Client, version 11.4.0 zabbixsv.local Creating a new client identity for ZABBIXSV using the validator key. zabbixsv.local resolving cookbooks for run list: [] zabbixsv.local Synchronizing Cookbooks: zabbixsv.local Compiling Cookbooks... zabbixsv.local [2013-03-25T17:25:54+09:00] WARN: Node ZABBIXSV has an empty run list. zabbixsv.local Converging 0 resources zabbixsv.local Chef Client finished, 0 resources updated
# knife node list ZABBIXSV
# knife bootstrap chefserv.local Bootstrapping Chef on chefserv.local Failed to authenticate root - trying password auth Enter your password: chefserv.local Starting Chef Client, version 11.4.0 chefserv.local Creating a new client identity for CHEFSERV using the validator key. chefserv.local resolving cookbooks for run list: [] chefserv.local Synchronizing Cookbooks: chefserv.local Compiling Cookbooks... chefserv.local [2013-03-25T17:29:57+09:00] WARN: Node CHEFSERV has an empty run list. chefserv.local Converging 0 resources chefserv.local Chef Client finished, 0 resources updated
# knife node list CHEFSERV ZABBIXSV
# knife ssh -x root -P $(head -1) "hostname:*" date P@ssw0rd! MYSQLSRV 2013年 3月 25日 月曜日 17:50:17 JST ZABBIXSV 2013年 3月 25日 月曜日 17:50:17 JST CHEFSERV 2013年 3月 25日 月曜日 17:50:17 JST
# cd ~/chef-repo/cookbooks # knife cookbook create install-zsh # cd install-zsh
# vi recipes/default.rb package "zsh" do action :install end
# knife cookbook upload install-zsh
# knife node run_list add CHEFSERV install-zsh
# knife ssh -x root -P $(head -n1) "hostname:CHEFSERV" chef-client CHEFSERV Recipe: install-zsh::default CHEFSERV * package[zsh] action install CHEFSERV (up to date) CHEFSERV Chef Client finished, 1 resources updated
# knife ssh -x root -P $(head -n1) "hostname:CHEFSERV" "rpm -qa | grep zsh" CHEFSERV zsh-4.3.10-5.el6.x86_64 #