binary installer
- Overview
- Features
- Getting Started
- Install
- Usage
- Configuration
- Output Format
- Tips
- Release Notes
- License
akoi
is a binary installer.
akoi
installs binaries according to the configuration file.
akoi
's task is simple.
- Download archives
- Unarchive downloaded archives
- Install binaries
- Create symbolic links to binaries
akoi
manages the binary's version with symbolic link.
For example,
/usr/local/bin/consul-1.2.1
/usr/local/bin/consul -> consul-1.2.1
- efficiency
- install packages in parallel
- support parallel download with Accept-Ranges
- declarative and idempotence
- small dependencies and easy to install (written in Go)
- work good with ansible's shell module
Install akoi. Generate the configuration file.
$ akoi init --dest akoi.yml
Edit the akoi.yml
.
In this section, install consul as example.
---
# akoi - binary version control system
# https://github.com/suzuki-shunsuke/akoi
bin_path: /tmp/bin/{{.Name}}-{{.Version}}
link_path: /tmp/bin/{{.Name}}
packages:
consul:
url: "https://releases.hashicorp.com/consul/{{.Version}}/consul_{{.Version}}_{{.OS}}_{{.Arch}}.zip"
version: 1.2.1
files:
- name: consul
archive: consul
Run the akoi install
command to install binaries.
$ akoi install -c akoi.yml
downloading consul: https://releases.hashicorp.com/consul/1.2.1/consul_1.2.1_darwin_amd64.zip
unarchive consul
create directory /tmp/bin
install /tmp/bin/consul-1.2.1
create link /tmp/bin/consul -> /tmp/bin/consul-1.2.1
Binaries are installed at the bin
directory.
Check bin directory.
$ ls /tmp/bin
consul -> consul-1.2.1
consul-1.2.1
Edit akoi.yml
to change the consul version to 1.2.0 and run akoi install
again.
$ akoi install -c akoi.yml
downloading consul: https://releases.hashicorp.com/consul/1.2.0/consul_1.2.0_darwin_amd64.zip
unarchive consul
install /tmp/bin/consul-1.2.0
remove link /tmp/bin/consul -> /tmp/bin/consul-1.2.1
create link /tmp/bin/consul -> /tmp/bin/consul-1.2.0
Run akoi install
again. akoi
does nothing. akoi
doesn't download files wastefully.
$ akoi install -c akoi.yml # output nothing
Edit akoi.yml
to change the consul version to 1.2.1 and run akoi install
again.
The consul 1.2.1 has already been installed so akoi
doesn't download the archive wastefully.
akoi
only recreates the symbolic link.
$ akoi install -c akoi.yml
remove link /tmp/bin/consul -> /tmp/bin/consul-1.2.0
create link /tmp/bin/consul -> /tmp/bin/consul-1.2.1
akoi is written with Golang and binary is distributed at release page, so installation is easy and no dependency is needed.
If you want to build yourself, run the following command.
$ go get -u github.com/suzuki-shunsuke/akoi
If you want to install akoi
with ansible, please consider to use the ansible role suzuki-shunsuke.akoi.
Check whether akoi is installed.
$ akoi -v
akoi version 0.3.1
Please run akoi help
or akoi help <command>
.
$ akoi help
$ akoi help [init|install]
The following fields in the configuration file are parsed by Go's text/template.
- bin_path
- link_path
- archive
- url
And in template, sprig functions can be used.
---
# bin_path and link_path are absolute path or relative path from the configuration file parent directory.
# binary install path
bin_path: $HOME/bin/{{.Name}}-{{.Version}}
# the symbolic link to the binary
link_path: $HOME/bin/{{.Name}}
# number of download partitions with Accept-Ranges
# Note that this parameter is ignored if server doesn't support Accept-Ranges.
# If this parameter is not set or is less equal than 0, the value of `runtime.NumCPU()` is used.
# If this parameter is 1, Accept-Ranges isn't used.
num_of_dl_partitions: 4
max_parallel_download_count: 5
http_request_timeout: 300
packages:
consul: # package name
# akoi downloads a file from this url and unarchive it according to the base file name.
# akoi uses https://github.com/mholt/archiver to unarchive the file.
# .OS and .Arch are got by runtime.GOOS and runtime.GOARCH .
# https://golang.org/pkg/runtime/#pkg-constants
url: "https://releases.hashicorp.com/consul/{{.Version}}/consul_{{.Version}}_{{.OS}}_{{.Arch}}.zip"
# package version
version: 1.2.1
# archive file's type. This is optional and by default this is decided by url's path.
# akoi uses mholt/archiver and the value included in archiver.SupportedFormat is supported.
# https://github.com/mholt/archiver
# If downloaded file is not archived, set archive_type to "unarchived".
# And the file type is compressed but not archived (not ".tar.gz"), set archive_type to "Gzip".
archive_type: Zip
# binary install path
bin_path: /usr/local/bin/{{.Name}}-{{.Version}}
# the symbolic link to the binary
link_path: /usr/local/bin/{{.Name}}
num_of_dl_partitions: 1
http_request_timeout: 120
# files included in the downloaded file
files:
- name: consul
# when unarchive the file to the temporary directory,
# the relative path from the directory to the file.
archive: consul
# file's mode. This is optional and default value is 0755.
mode: 0644
# binary install path
bin_path: /opt/bin/{{.Name}}-{{.Version}}
# the symbolic link to the binary
link_path: /opt/bin/{{.Name}}
Configuration file path. The precedence is
- command line option
- AKOI_CONFIG_PATH
- finds the file .akoi.yml from the current directory to the root directory recursively
- /etc/akoi/akoi.yml
Note that this specification is unstable.
{
"msg": "",
"changed": true,
"failed": false,
"packages": {
"consul": {
"name": "consul",
"changed": true,
"failed": false,
"error": "",
"version": "1.2.1",
"url": "https://releases.hashicorp.com/consul/1.2.1/consul_1.2.1_darwin_amd64.zip",
"files": {
"consul": {
"name": "consul",
"error": "",
"changed": true,
"migrated": false,
"installed": true,
"mode_changed": false,
"file_removed": false,
"dir_created": false,
"link": "consul",
"entity": "consul"
}
}
}
}
}
If you want to install binaries with ansible, run akoi install
command with --format
option in ansible's shell module.
When --format
option is set akoi install
outputs the result as json.
$ akoi install -f ansible | jq '.'
{
"msg": "",
"changed": false,
"packages": {
"consul": {
"error": "",
"changed": false,
"state": "",
"files": [
{
"error": "",
"changed": false,
"state": "",
"name": "consul",
"link": "",
"entity": ""
}
],
"version": "1.2.1",
"url": ""
}
}
}
So you can check whether the task's result by passing the output.
tasks:
- name: install consul
shell: "/usr/local/bin/akoi install -f ansible 2>&1"
register: result
changed_when: (result.stdout|from_json)["changed"]
Please see Releases.