This is a tool to build, test, and deploy your projects to either another
server or to a clone system for deployment
by clone.
The installation for push is not the most standard. Configuration files must
be written before it can be deployed. So follow these steps to get those
created.
-
Edit
pushlib/loader.py. There are a few specific configuration value that MUST be set. These can all be overridden in a project's.pushrcfile.-
env.clone_base_diris the path on your clone system (see clone) to where all sources can be found. This should be set to something like/clone/sources. -
env.clone_pathis the default clone source directory to use on theclonesystem when deploying projects. This might be something likepush/commonand is appended to theenv.clone_base_dir. This should generally be set by the project's.pushrcfile but you can set a default value here. -
env.host_pathis the default root directory on the remote host to which projects will be deployed. This might be something like/srv/wwwand, when deploying to theclonesystem, this will be appended toenv.clone_path. -
env.host_useris the default user on the remote host that the project will be deployed as. This user must be one that the user cansudoto on remote the remote hosts to which one will be deploying. This might be something likewwworops.
-
-
Maybe modify
pushlib/hosts.py. This is where hosts are defined by either name or tag. Right now the host is list loaded from a tool called dart but you can get the list of hosts from wherever you want. -
You may decide to install
pushto theclonesystem so that it may be installed later usingcloneor you may decide to install it directly to a host to start using now.-
To deploy to the local host you can run this:
./push live localhostThat will deploy the project to the same system on which you are currently running. It will do the deployment with
sshandsudo. -
To deploy to a host defined in
bin/servers.pyyou can run this:./push live some-hostThat will deploy the project to the system defined in your server configuration list. It will do the deplyment with
sshandsudo. -
To deploy to an abritrary host you can use that host name and confirm that you're ok with deploying to that host.
./push live random-host -
To deploy to the
clonesystem you can run this:./push cloneThat will deploy the project to the defined
clonehost usingsshandsudo.
-
To use push to deploy your project, you need to create a file called
.pushrc in the root directory of your project. Decide what type of deployment
you need to have. Only one type of deployment is included by default but there
are examples of other deployment types in the /contrib directory.
-
copy
This type of deployment is for just copying a project's files to the remote location. The default only copies five directories:
bin,lib,etc,www, andweb. Examples of how to copy others are detailed below.Here is an example
.pushrcusing thecopydeployment type that will put your project into thepush/commondirectory on yourclonesystem:# vi:syntax=python from pushlib.modules.perl import * env.clone_path = "push/common"You can make it copy more than just
bin,lib,etc,www, andweb. To make it also copy thefoobardirectory, for example:# vi:syntax=python from pushlib.modules.perl import * from pushlib.tools import copy env.clone_path = "push/common" class BuildTask(BuildTask): def before(self, c): super().before(c) for path in ["foobar"]: copy("foobar")To override where files go -- for example, to have files in the project's bin directory deploy to foobar/bin -- you can use this example:
copy("bin", "foobar/bin")
If the multiple deployment types implement other tasks such as Clean or
Archive then you will have to write those into your script as well.
push is just a series of Fabric scripts. After configuring your project's
.pushrc file you can see what tasks you may run using push -l:
$ push -l
Subcommands:
archive create deployment archive
build build the project
clean remove all build artifacts
clone deploy the project to clone
live deploy the project using "live nickname" to deploy to a particular host
mostlyclean remove most build artifacts
register registers the task with dart if a .dartrc file is present
test run project tests
You can implement a subclassed version of one of these tasks to override its functionality. Going the subclassed route is probably best because it ensures the enforcement of prerequisites for each target.
An important note is that by default push only adds new files. push does
not remove files from remote hosts that have been removed from your project.
You must remove those from the remote host yourself.
The following are the default tasks available by default when using push.
Each task is implemented by Python class and can be overridden to add or
remove functionality. Each of the above described modules does just that and
implements its own class that can also be overridden in the same way.
- clean
Cleans up all build artifacts.
- build
Builds the project but does not run tests.
- test
After building the project this will run all tests.
- archive
After building and testing the project this creates a deployment archive of the project. The deployment archive is exactly what will get sent to the host.
- live nickname
Installs the project on a remote host where the nickname is the host alias
defined in the hosts.py file. It does this over ssh. All files are
installed using sudo on the remote host to the configured user.
- clone
Installs the project into the defined clone_path directory on the clone
host. It does this over ssh. All files are installed using sudo on the
defined clone host to the configured user.
There are several flags that can be used to control the operation of push. These flags can all be passed to push like this:
NO_TAG=1 push ...
The values "True" or "1" will enable setting and anything else will disable the
setting. The other way to set this flags is permanently in the project's
.pushrc file like this:
env.no_tag = True
env.no_tag = 1
Normally a project will be not be deployed to the clone host if the version being deployed is not tagged. This will allow an untagged project to be deployed.
This project is just a series of Python scripts with classes that extend Fabric
classes and that can be further extended very easily using more inheritance and
even multiple inheritance. In any extension to push, you can access the
following variables using Fabric's global env variable.
env.current_dirThis is the full path to the current directory from wherepushwas called.env.containment_dirThis is the root path wherepushdoes its work.env.build_dirThe full path to the directory where the project is built.env.test_dirThe full path to the directory where test output is sent.env.archive_dirThe full path to the directory where where archives created by the archive task will be stored.env.release_dirThe full path to the directory where the release will be created. Basically, anything that goes in here will be deployed when the project is deployed.env.git_root_dirThe full path to the root of the git repository in which the project is contained.env.repo_commit_nameenv.repo_branch_hameenv.repo_tag_nameenv.repo_is_dirtyenv.project_nameThe name of the project derived from the name of the git directory.env.archive_nameThe name of the archive created when running the archive task.env.clone_base_dirThe root clone source directories.env.clone_pathThe clone source directory to use when deploying toclone.env.host_pathThe directory to deploy your project to on remote systems.env.host_userThe user tosudoto when deploying to remote systems.
This software requires:
- Python 3
- Invoke
- rsync
- git
It also requires standard system utilities in your path like ssh and sudo.
This project is a derivation of a similar project created and used internally by the University of Washington Information Technology IT Infrastructure division. The code seen here was created by Paul Lockaby.