chef-cookbooks / aix

Resources for AIX hosts
https://supermarket.chef.io/cookbooks/aix
Apache License 2.0
23 stars 42 forks source link
aix chef cookbook hacktoberfest

AIX Cookbook

Build Status Cookbook Version

This cookbook contains useful resources for using Chef with AIX systems.

Requirements

Platforms

Chef

Cookbooks

Usage

This cookbook ships multiple resources for writing cookbooks to manage AIX hosts. See the resources below:

Resources

altdisk

Create an alternate disk on a free disk Update an existing alternate disk

Actions

Properties

Examples

aix_altdisk "cloning rootvg by name hdisk3" do
  type :name
  value "hdisk3"
end

aix_altdisk "cloning rootvg by size 66560" do
  type :size
  value "66560"
end

aix_altdisk "cloning rootvg by size 66561" do
  type :size
  value "66561"
end

aix_altdisk "cloning rootvg by auto" do
  type :auto
  value "bigger"
  action :create
  altdisk_name "myvg"
end

aix_altdisk "cleanup alternate rootvg" do
  action :cleanup
  altdisk_name "rootvg_alt"
end

aix_altdisk "altdisk_by_auto" do
  type :auto
  value "bigger"
  change_bootlist true
  action :create
end

aix_altdisk "altdisk_wake_up" do
  action :wakeup
end

aix_altdisk "altdisk_update" do
  image_location "/mnt/7100-03-05-1524"
  action :customize
end

aix_altdisk "altdisk_sleep" do
  action :sleep
end

aix_altdisk "rename altdisk" do
  new_altdisk_name "altdisk_vg"
  action :rename
end

inittab

Manage the inittab entries. Example:

Properties

Examples

aix_inittab 'my-awesome-aix-daemon' do
  runlevel '2'
  processaction 'once'
  command '/opt/mycompany/libexec/mydaemon -d > /dev/console 2>&1'
  action :install
end

subserver

Manage the services started by inetd by editing /etc/inetd.conf.

Properties

Examples

aix_subserver 'tftp' do
  protocol 'udp'
  action :disable
end

tcpservice

Manage the services started by /etc/rc.tcpip.

Properties

Examples

aix_tcpservice 'xntpd' do
  action :enabled
end

toolboxpackage

To install packages from the IBM AIX Toolbox for Linux off the IBM FTP site.

Properties

Examples

aix_toolboxpackage "a2ps" do
  action :install
end

chdev

Change any AIX device attribute.

Properties

Examples

aix_chdev 'sys0' do
  attributes(maxuproc: '1026', ncargs: '1024')
  need_reboot false
  action :update
end

aix_chdev 'fcs0' do
  attributes(num_cmd_elems: '200', max_xfer_size: '0x800000')
  need_reboot true
  action :update
end

aix_chdev 'ent0' do
  attributes(poll_uplink: 'yes')
  need_reboot true
  action :update
end

aix_chdev 'hdisk1' do
  attributes(reserve_policy: 'no_reserve')
  hot_change true
  action:update
end

pagingspace

Create, remove, modify AIX paging space.

Properties

Actions

Examples

aix_pagingspace "Changing paging space" do
  name 'hd6'
  size 1024
  auto true
  action :change
end

aix_pagingspace "Disabling paging space" do
  name 'paging00'
  active false
  action :change
end

aix_pagingspace "Removing paging space" do
  name 'paging00'
  action :remove
end

aix_pagingspace "Creating paging space" do
  name 'mypgsp'
  size 1024
  auto true
  vgname 'rootvg'
  action :create
end

aix_pagingspace "Creating paging space 2" do
  name 'mypgsp2'
  size 1024
  auto true
  active true
  vgname 'rootvg'
  action :create
end

no

Change any AIX no (network) tunables.

Properties

Actions

Examples

aix_no "changing no tunables" do
  tunables(udp_recv_perf: '0', udprecvspace: '42083', psetimers: '23')
  set_default
  action :update
end

aix_no "reseting no tunables" do
  tunables(udp_recv_perf: '0', udprecvspace: '0')
  set_default false
  action :reset
end

aix_no "reseting all no tunables" do
  action: reset_all
end

aix_no "reseting all no tunables reboot needed" do
  action: reset_all_with_reboot
end

tunables

Change any AIX unrestricted tunables(vmo, ioo, schedo).

Properties

Actions

Examples

aix_tunables "reset schedo values" do
  mode :schedo
  action :reset_all
  permanent
end

aix_tunables "change vpm_throughput_mode" do
  mode :schedo
  tunables(:vpm_throughput_mode => 2)
  permanent
end

aix_tunables "change posix AIO servers" do
  mode :ioo
  tunables(posix_aio_minservers: 6, posix_aio_maxservers: 36)
end

aix_tunables "tune minperm%" do
  mode :vmo
  tunables( :"minperm%" => 6)
  permanent
end

aix_tunables "tune tcp buffers" do
  mode :no
  tunables( :udp_recvspace => 655360, :udp_sendspace => 65536 )
  permanent
end

multibos

Create, remove or update multibos on AIX.

Properties

Actions

Examples

aix_multibos "create a multibos no bootlist" do
  action :create
  bootlist true
end

aix_multibos "create and update a multibos" do
  action :create
  update_device "/mnt/7100-03-05-1524"
end

aix_multibos "remove standby multibos" do
  action :remove
end

aix_multibos "update a multibos" do
  action :update
  update_device "/mnt/7100-03-05-1524"
end

aix_multibos "mount a bos" do
  action :mount
end

aix_multibos "mount a bos" do
  action :umount
end

chsec

Changes the attributes in the security stanza files.

Properties

Examples

aix_chsec '/etc/security/login.cfg' do
  attributes(maxlogins: '16000', maxroles: '7', shells: '/bin/sh,/usr/bin/ksh')
  stanza 'usw'
  action :update
end

etchosts

Add, change or remove entries in the /etc/hosts file.

Properties

Actions

To ensure an entry is added and stays set correctly, use both the :add and :change actions as shown in the 5th example below.

Examples

aix_etchosts "test" do
  ip_address "1.1.1.1"
  action :add
end

aix_etchosts "test" do
  ip_address "2.2.2.2"
  action :change
end

aix_etchosts "test" do
  new_hostname "test2"
  action :change
end

aix_etchosts "test" do
  ip_address "1.1.1.1"
  aliases ["test2", "test3"]
  action :add
end

aix_etchosts "test" do
  action :delete
end

aix_etchosts '1.1.1.4' do
  aliases ['test4', 'test5']
  action [:add, :change]
end

aix_etchosts "1.1.1.4" do
  action :delete
end

aix_etchosts "delete all entries" do
  action :delete_all
end

suma

Use suma to download fixes on a NIM server. You can download service pack, or technology level. You can also download latest service pack of latest technology level for the HIGHEST release in the client list. It means if you provide AIX 7.1 and 7.2 clients, only last 7.2 TL or SP is downloaded.

In some cases a metadata operation is performed to discover the oslevel build number or the latest service pack level.

The location directory is automatically created if it does not exist.

The NIM lpp_source resource is automatically created if needed. It meets the following requirement. Name contains build number and ends with the type of resource:

You can provide a NIM lpp_source as oslevel property.

Suma resource uses Ohai to discover nim environment. You may want to reload Ohai info after a successful download by adding:

aix_suma "download needed fixes to update client list to 7.1 TL3 SP1" do
  oslevel "7100-03-01-1341"
  location "/export/extra/nim"
  targets "client1,client2,client3"
  action :download
end

aix_suma "... perform suma metadata operation to discover build number" do
  oslevel "7100-03-01"
  location "/export/extra/nim"
  targets "client1,client2,client3"
  action :download
end

aix_suma "download needed fixes to update client list to 7.1 TL4" do
  oslevel "7100-04"
  location "/export/extra/nim"
  targets "client1,client2,client3"
  action :download
end

aix_suma "download needed fixes to update client list to last TL and last SP" do
  oslevel "latest"
  location "/export/extra/nim"
  targets "client1,client2,client3"
  action :download
end

aix_suma "update nim lpp_source with needed fixes" do
  oslevel "7100-03-01-1341-lpp_source"
  location "/export/extra/nim"
  targets "client1,client2,client3"
  action :download
end

Properties

Actions

nim

Use nim to setup a NIM server or install packages, update service pack, or technology level. Your NIM lpp_source must match the exact oslevel output.

Properties

Actions

Examples

To install the following updates:

Use:

aix_nim "setup nim server" do
  device "/mnt"
  action :master_setup
end

aix_nim "asynchronously updating clients" do
  lpp_source "7100-03-01-1341-lpp_source"
  targets "client1,client2,client3"
  async    true
  action :update
end

aix_nim "updating clients to latest SP (forced synchronous)" do
  lpp_source "latest_sp"
  targets "client1,client2,client3"
  action :update
end

aix_nim "updating clients to latest TL (forced synchronous)" do
  lpp_source "latest_tl"
  targets "client1,client2,client3"
  action :update
end

flrtvc

Use flrtvc tool to generate flrtvc report, download recommended efix, and install them to patch security and/or hiper vulnerabilities.

A nim lpp_source resource is automatically created for fixes to be installed. It is removed at the end of the installation.

If space is needed, filesystem is automatically extended by increment of 100MB.

Properties

Actions

Examples

aix_flrtvc "install flrtvc tool (download unzip if needed)" do
  action :install
end

aix_flrtvc "download and install recommended efixes locally" do
  action :patch
end

aix_flrtvc "download and install security vulnerabilities on the remote targets" do
  apar "security"
  targets "client1,client2,client3"
  action :patch
end

aix_flrtvc "download and install hiper issues" do
  apar "hiper"
  targets "client1,client2,client3"
  action :patch
end

aix_flrtvc "download and install efix for printers fileset(s)" do
  filesets "printers"
  targets "client1,client2,client3"
  action :patch
end

aix_flrtvc "use custom csv file" do
  csv "/tmp/apar.csv"
  targets "client1,client2,client3"
  action :patch
end

aix_flrtvc "generate flrtvc report only" do
  path '/tmp/flrtvc'
  check_only true
  action :patch
end

aix_flrtvc "download recommended efixes only" do
  path '/tmp/flrtvc'
  download_only true
  action :patch
end

nimviosupdate

Use nimviosupdate to update a VIOS or a couple of VIOSes by installing software from the NIM server. Each action from the action list can be executed independently or together: check, altdisk_copy, update, altdisk_cleanup action_list:

Properties

Actions

Examples

aix_nimviosupdate "check the vios redundancy" do
  targets "(vios1,vios2),(vios3,vios4)(vios5)"
  action_list "check"
  action :update
end

aix_nimviosupdate "build an alternate rootvg" do
  targets "(vios1,vios2),(vios3,vios4),(vios5)"
  altdisks "(hdisk1,hdisk2)(hdisk1,)()"
  action_list "altdisk_copy"
  action :update
end

aix_nimviosupdate "update VIOSes using lpp_source " do
  lpp_source "lpp_source_name"
  targets "(vios1,vios2),(vios3,vios4),(vios5)"
  action_list "update"
  updateios_flags "install"
  accept_licenses "yes"
  preview "no"
  action :update
end

aix_nimviosupdate "remove alternate rootvg" do
  targets "(vios1,vios2),(vios3,vios4),(vios5)"
  action_list "altdisk_cleanup"
  action :update
end

aix_nimviosupdate "check VIOSes tuples, make alternate rootvg, update VIOSes, remove alternate rootvg" do
  lpp_source "lpp_source_name"
  targets "(vios1,vios2),(vios3,vios4),(vios())"
  altdisks "(,)(,),()"
  updateios_flags "install"
  accept_licenses "yes"
  preview "no"
  action_list "check,altdisk_copy,update,altdisk_cleanup"
  action :update
end

niminit

Use niminit to configure the nimclient package. This will look if /etc/niminfo exists and create it if it does not exist. You can the use nimclient provider after niminiting the client.

Properties

Actions

Examples

aix_niminit node[:hostname] do
  master "nimmaster"
  connect "nimsh"
  pif_name node[:network][:default_interface]
  action :setup
end

aix_niminit node[:hostname] do
  action :remove
end

aix_niminit node[:hostname] do
  master "nimmaster"
  connect "nimsh"
  pif_name "en1"
  action :setup
end

nimclient

Use nimclient to install packages, update service pack, or technology level. Your NIM server should meet these requirements to work with the nimclient provider:

Recommendation: create all the lpp_source with the simage attribute to avoid ambiguity.

$ lsnim -l 7100-03-05-1524-lpp_source
7100-03-05-1524-lpp_source:
   class       = resources
   type        = lpp_source
   arch        = power
   Rstate      = ready for use
   prev_state  = unavailable for use
   location    = /export/nim/lpp_source/7100-03-05-1524
   simages     = yes
   alloc_count = 1
   server      = master

Here are a few examples of recipes using nimclient:

aix_nimclient "updating to latest available sp" do
  installp_flags "aXYg"
  lpp_source "latest_sp"
  fixes "update_all"
  action :cust
end

aix_nimclient "installing filesets from the latest available tl" do
  installp_flags "aXYg"
  lpp_source "latest_tl"
  filesets ["openssh.base.client","openssh.base.server","openssh.license"]
  action :cust
end

aix_nimclient "installing filesets from the next sp" do
  installp_flags "aXYg"
  lpp_source "next_sp"
  filesets ["security.pkcs11.tools"]
  action :cust
end

aix_nimclient "installing filesets" do
  installp_flags "aXYg"
  lpp_source "latest_sp"
  filesets ["Java6_64.samples"]
  action :cust
end

aix_nimclient "reset" do
  action :reset
end

aix_nimclient "deallocate" do
  action :deallocate
end

aix_nimclient "set date to nimmaster value" do
  action :set_date
end

aix_nimclient "disable push operations" do
  action :disable_push
end

aix_nimclient "enable push operations" do
  action :enable_push
end

aix_nimclient "maintbooting client" do
  spot "7100-03-01-1341-spot"
  action :maint_boot
end

aix_nimclient "bos_inst client" do
  spot "7100-03-01-1341-spot"
  lpp_source "7100-03-01-1341-lpp_source"
  action :bos_inst
end

aix_nimclient "allocating resources" do
  installp_bundle "toolbox-installp_bundle"
  lpp_source "7100-03-01-1341-lpp_source"
  spot "7100-03-01-1341-spot"
  action :allocate
end

Properties

Actions

bootlist

Change AIX bootlist.

Properties

Actions

Examples

aix_bootlist 'invalidate normal mode bootlist' do
  action :invalidate
  mode :normal
end

aix_bootlist 'set normal and service bootlist on hdisk0' do
  mode :both
  devices ["hdisk0"]
end

aix_bootlist 'set bootlist for normal mode' do
  mode :normal
  devices ["hdisk0","hdisk1"]
  device_options("hdisk0" => "pathid=0", "hdisk1" => "pathid=0,1")
end

fixes

Install and remove fixes

Properties

Actions

Examples

aix_fixes "removing all fixes" do
  fixes ["all"]
  action :remove
end

aix_fixes "installing fixes" do
  fixes ["IV75031s5a.150716.71TL03SP05.epkg.Z", "IV77596s5a.150930.71TL03SP05.epkg.Z"]
  directory "/root/chefclient"
  action :install
end

aix_fixes "removing fix IV75031s5a" do
  fixes ["IV75031s5a", "IV77596s5a"]
  action :remove
end

volume_group

Create or modify a LVM volume group

Properties

Actions

Examples

# Create volume groupe 'datavg1' with 2 disks
aix_volume_group 'datavg1' do
  physical_volumes          ['hdisk1', 'hdisk2']
  action :create
end

# Modify existing volume groupe 'datavg1' and add new disk
aix_volume_group 'datavg1' do
  physical_volumes          ['hdisk1', 'hdisk2', 'hdisk3']
  action :create
end

# Create a volume group called `datavg2` comprising 3 disks and assign them to a mirror pool.
aix_volume_group 'datavg2' do
  physical_volumes ['hdisk4', 'hdisk5', 'hdisk6']
  mirror_pool_name   'copy0pool'
  action :create
end

# Add a disk as a hot spare to the same `datavg3` volume group
aix_volume_group 'datavg3' do
  physical_volumes ['hdisk7']
  use_as_hot_spare   'y'
  action :add
end

logical_volume

Create or modify a LVM logical volume

Properties

Actions

Examples

# create logical volume 'home' of 512MB with 2 copies in volume group 'datavg'
aix_logical_volume 'home' do
  group 'datavg'
  size   512 //  MB
  copies 2
  action :create
end

filesystem

Create, modify, mount or defrag a LVM filesystem

Properties

Actions

Examples

# create filesystem of 256Mb in '/lvm/folder1' on logical volume 'part1'
aix_filesystem '/lvm/folder1' do
  logical 'part1'
  size   '256M'
  action :create
end

# mount '/lvm/folder1' filesystem
aix_filesystem '/lvm/folder1' do
  action :mount
end

# defrag '/lvm/folder1' filesystem
aix_filesystem '/lvm/folder1' do
  action :defragfs
end

# umount '/lvm/folder1' filesystem
aix_filesystem '/lvm/folder1' do
  action :umount
end

wpar

Manage wpar

install aix-wpar gem

The cookbook itself will install the aix-wpar gem if the system as internet access.

Else you need to download the gem file here. And install the package on the AIX system:

/opt/chef/embedded/bin/gem install /tmp/aix-wpar-0.1.0.gem

Properties

Actions

Examples

aix_wpar 'create wpar' do
  action :create
  name 'testwpar'
  hostname 'testwpar'
  cpu '10%-50%,100%'
  live_stream true
  autostart true
end

aix_wpar 'stop wpar' do
 action :stop
 name 'testwpar'
 live_stream true
end

aix_wpar 'sync wpar' do
 action :sync
 name 'testwpar'
end

aix_wpar 'delete wpar' do
 action :delete
 name 'testwpar2'
end

License and Authors

Copyright 2008-2017, Chef Software, Inc.
Copyright 2015-2016, Alain Dejoux <adejoux@djouxtech.net>
Copyright 2015-2016, Benoit Creau <benoit.creau@chmod666.org>
Copyright 2015-2016, Bloomberg Finance L.P.
Copyright 2016, Atos <jerome.hurstel@atos.net>
Copyright 2016, International Business Machines Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.