The push.php-file is the interface to the user. It allows to:
and a few other things.
push.php
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
Available commands:
help Displays help for a command
list Lists commands
configuration
configuration:allgenerate Generate configuration for all associated templates/confs (and copy non-template files) for host(s) from inventory
configuration:diffsync Diff or sync configuration from local directories to remote host(s) from inventory
configuration:generate Generate configuration from templates (and copy non-template files) for host(s) from inventory
dynamic
dynamic:acquire Acquire dynamic data from host(s) from inventory
dynamic:show List and show dynamic data for host(s) from the inventory
inventory
inventory:add Add a host to the inventory
inventory:check Check IP attribute for host(s) from the inventory
inventory:list List and show attributes for host(s) from the inventory
inventory:remove Remove a host from the inventory
inventory:set Set attribute for a host in the inventory
push
push:active Shows hosts that react to a 'ping'
push:command Executes for the given hosts the given template command
push:openssh Shows hosts with open ssh port
push:poweroff Powers down hosts with no logged in users or lists the logged in users
push:reboot Reboots hosts with no logged in users or lists the logged in users
push:wakeonlan Wake on Lan
Note that all commands are prefix-unique and that this allows to call a command in a faster way. For example instead of using:
configuration:allgenerate
you could simply use c:a
push:difffiles
you could simply use p:d
The general work flow when using push to handle host configuration files is to:
network.json
-file by hand if need be. This is the case whenever a new network host group is added. (see: network.json)inventory.json
-file using the inventory:xxx
-commands of push. (see: inventory.json)dynamic:acquire
.configuration:xxx
-commands of push.configuration:diffsync
-command of push.configuration:diffsync
-command of push.Here's what each of the command is used for.
The help command displays help for a given command.
push.php help [options] [--] [<command_name>]
Calling
push.php help --format=xml list
shows the help for the list command as xml.List the known commands optionally in a specific format and only for a given namespace.
push.php list [--raw] [--format FORMAT] [--] [<namespace>]
The configuration:allgenerate
-command is used to generate the configuration files for a given host, or each host from a given group, and all the templates the host is associated to.
push.php configuration:allgenerate [-c|--clear] [--] <templates folder> <target> <group>
Calling
push.php configuration:allgenerate /root/push/var/ /root/push/tmp server02 -c
will check whether a 'server02'-subfolder inside the '/root/push/tmp'-folder exists and delete it in case it does. After this a new 'server02'-subfolder will be created and all generated configuration files will be placed into it.push.php configuration:allgenerate /root/push/var/ /root/push/tmp server02
will create a new 'server02'-subfolder inside the '/root/push/tmp'-folder in case it doesn't exist. In case the folder exists only generated files will be overwritten. Files which are not covered by an associated template will remain untouched.push.php configuration:allgenerate /root/push/var/ /root/push/tmp workstations -c
will clear and recreate the configuration files for all hosts inside the workstations-group and their associated templates.To be on the save side of things, it is adviced to always use the -c
-parameter together with the configuration:generateall
command to make sure no lingering old files are accidentally pushed to a host.
The configuration:diffsync
-command is used to compare either compare the content of a folder agains a remote folder or push/synchronize a given folder to a target host (or hosts inside a group).
push.php configuration:diffsync [-s|--sync] [--] <source> <target> <group>
Calling
push.php configuration:diffsync /root/push/var/ / servers
compares the content of the '/root/push/var/push.php configuration:diffsync /root/push/var/ /var/tmp server02 -s
synchronizes/copies the content of the local '/root/push/var/server02'- to the '/var/tmp'-folder on host (server02).
Important: One should always first compare a generated configuration against the target host before synchronizing/copying it to the target. Only add -s|--sync
after you made sure the changes are okay.The configuration:generate
-command is used to generate the configuration files of a single template for a host or a group of hosts. Calling this command with different templates allows to combine multiple templates. Note that this also allows to generate configuration files for templates which are normally not associated to a host.
When adding a new client to the inventory this also allows to just update the DHCP and/or DNS configuration of a server without having to care about any other configuration. (see: 'Server/Rechner hinzufügen')
push.php configuration:generate [-c|--clear] [--] <source> <target> <group>
Calling
push.php configuration:generate /root/push/var/kerberos_client /root/push/tmp pc07 -c
would delete the '/root/push/tmp/pc07'-folder in case it existed. Create a new '/root/push/tmp/pc07'-folder and put the files form the evaluation og the kerberos_client-template inside it.push.php configuration:generate /root/push/var/client /root/push/tmp pc42 -c
push.php configuration:generate /root/push/var/kerberos_client /root/push/tmp pc42
push.php configuration:generate /root/push/var/server_lxd /root/push/tmp pc42
would create a configuration for pc42 based on the client-, kerberos_client- and server_lxd-template.
Most of the time this command is probably not needed since normally configuration:allgenerate
is the better way to go.
The `dynamic:acquire-command is ment to aquire some host specific data from the target host which will be saved inside the tmp/dynamic.json-file and thus be available during processing of the templates.
push.php dynamic:acquire <group> <attributes> (<attributes>)...
Calling
push.php dynamic:acquire pc07 interface fstab
updates the tmp/dynamic.json-file with the newly collected data for pc07.push.php dynamic:acquire workstations interface
updates the tmp/dynamic.json-file with the newly collected data for all hosts associated with the workstations-group. This call will on update the interface-data, any existing fstab-data will be untouched through this.Note: When collecting fstab-data all entries from the fstab of the host will be collected. Thus one needs to check that only the wanted entries are stored inside the tmp/dynamic.json-file. Typically only entries which map to physical devices are wanted. Mounting of network shares or similar should be covered through templates and not be part of the dynamic.json-file.
Shows all or parts of the collected dynamic data for a host or a group of hosts.
push.php dynamic:show <group> [<attributes>]...
Calling
push.php dynamic:show servers
shows all the dynamic data collected for any host associated to the servers-group.push.php d:s server02 fstab
shows just the fstab-data for server02.Adds a new host entry to the inventory, but can also be used to associate the host with a group.
push.php inventory:add [-m|--mac MAC] [-g|--group GROUP] [--] <name>
Calling
push.php inventory:add -m de:le:te:me pc99
would create a new entry inside the inventory.
Assuming there is a hostgroup named 'pc' with a range of '192.168.0.23' the entry will look like this:
"pc99": {
"mac": "de:le:te:me",
"ip4": "192.168.0.99"
},
Note that the 'ip4' automatically gets assigned using the range of the hostgroup and the number from the name.
push.php inventory:add -g workstations pc99
would associate the host (pc99) to the workstations group. This would expand the above pc99-entry to:
"pc99": {
"mac": "de:le:te:me",
"ip4": "192.168.0.99",
"groups: {
"workstations*
}
},
Checks whether a host or all hosts of a group have an IP and whether its 'ip4'-value inside the inventory.json matches the ip it should have based on it's name (and hostgroup association).
inventory:check [-r|--repair] [--] <group>
Calling
push.php i:c all
checks for each of the hosts whether it got the expected ip4 value.push.php inventory:check --repair pc99
repairs the ip4 value of the host named pc99 based on it's name and hostgroup association.List attributes inside the inventory for a host or all hosts associated to a group.
push.php inventory:list [-a|--attribute ATTRIBUTE] [-A|--all] [--] <group>
Calling
push.php i:l workstations
, a list of all the names of all hosts associated to the workstations-group will be shown.push.php i:l server_ldap
, a list of the names of all hosts associated to the server_ldap-group will be shown.push.php i:l -a ip4 server_nfs
, a list of all NFS servers and their ip4-attribute will be shown.push.php i:l -a ip4 server04
, the hostname and ip4 of server04 will be shown..push.php i:l -a groups all
, a list of all hosts and their associated groups will be shown.push.php i:l -a ip4 -a groups pc07
, the ip4- and the groups-value of host pc07 will be shown.A typical usage example for this is when a new host should be added but one doesn't know the name that was used for a the last host in the targeta hostgroup. So when adding a new PC we would first call push.php i:l workstations
to see which names are already taken. With pc20
being the last workstation inside the inventory we would name the new workstation pc21
.
Removes a given host from the inventory. Note that there is no saveguard so only use this if you really want to remove a host from the inventory. This will not change the content of the dynamic.json-file.
push.php inventory:remove <name>
Calling
push.php inventory:remove pc17
will removes the data entry for pc17 from the inventory.json-file.Set a an attribut for a host.
push.php inventory:set [-a|--array] [-c|--clear] [-r|--remove] [--] <name> <attribute> [<values>]...
Calling
push.php inventory:set -r -- pc07 ip4
will remove the 'ip4' attribute of host pc07 from the inventory. I case of the 'ip4'-attribute, this could be repaired using push.php inventory:check -r pc07
.push.php i:s -c pc07 confs
will remove all entries inside the 'confs' array for host pc07.push.php i:s -c pc07 confs client
will remove all entries inside the 'confs' array for host pc07 and then add 'client' as a new entry.push.php i:s pc07 description "What a wonderful day!"
will add an attribute named description (in case it doesn't exist) to host pc07 and set it's value to 'What a wonderful day!'.push.php -a i:s pc07 testing 1 2 3
will create an array called testing with the entries: 1:1, 2:1 and 3:1 to the host pc07. If there already is an array called 'testing' the new values will be added if they don't exist. If there is an attribut named 'testing' which isn't an array, the attribut will be converted to an array keeping it's existing value(:1) and adding the new values.push.php i:s pc07 test 2 3
will create an array names 'test' and add '2:1' and '3:1' as values in case test doesn't exist. If test exists and is an array '2:1' and '3:1' will be added in case they don't exist. If test isn't an array but exists the command will first set the value of 'test' to '2:1' and then to '3:1'.To keep things simple always use '-a|--array' when dealing with arrays.
Shows hosts that react to a 'ping', which is a decent indicator to determine whether the host is active/online or not.
push.php push:active <group>
Calling
Call a specific command on a host or group.
push.php push:command <group> <template>
Note that this will show the output of the called command, but it does not offer any additional interaction with the host. So you will be stuck when a command requires additional user input.
Calling
push.php push:command workstations "apt-get update"
will connect to each host associated to the 'workstations'-group and call apt-get update
on it.push.php push:command pc07 "apt-get -y dist-upgrade"
will connect to host pc07 and call apt-get -y dist-upgrade
on it.Note that the template-command by default will be called as the current user (typically root), if you want to call it as another user you need to adjust the template-call to execute your command as another user. In example by using something like sudo -u <remoteuser> sh -c <command>
as template-call.
Checks whether the open ssh port (22) is open on the host/group. Since most non-pcs to not support ssh and consequentyl don't have an open ssh port you might want to use push:active
instead to determine if those hosts are active.
push.php push:openssh <group>
Calling
push.php push:openssh workstations
will report which host associated to the workstations-group have an open port 22.Turns off a host or group of hosts with no logged in users or lists the logged in users.
push.php push:poweroff <group>
Calling
push.php push:poweroff workstations
connects to each host associated to the workstations group, checks the number of users that are logged in and, if there are no other users logged in, shuts the host down. In case other users are logged in, the user list will be printed.Reboots a host or group of hosts with no logged in users or lists the logged in users.
push.php push:reboot <group>
Calling
push.php push:poweroff reboots
connects to each host associated to the workstations group, checks the number of users that are logged in and, if there are no other users logged in, reboots the host. In case other users are logged in, the user list will be printed.Sends a wake-on-lan magic ethernet package to the host or groups of hosts.
push.php push:wakeonlan <group>
Calling
push.php push:wakeonlan all
send a magic package for wake-on-lan to each of the hosts.Here are some general remarks for using the push.php
executable.
ssh-copy-key <hostIP>
on the server)