Fileconsul is sharing files(configuration file, Service/Check definition scripts, handler scripts and more) in a consul cluster.
Run fileconsul -h
to see the usage help:
$ fileconsul -h
NAME:
fileconsul - Sharing files in a consul cluster.
USAGE:
fileconsul [global options] command [command options] [arguments...]
VERSION:
0.1.0
COMMANDS:
status Show status of local files
pull Pull files from a consul cluster
push Push file to a consul cluster
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--version, -v print the version
--help, -h show help
Run fileconsul status -h
to see the usage help:
$ fileconsul status -h
NAME:
status - Show status of local files
USAGE:
command status [command options] [arguments...]
DESCRIPTION:
Show the difference between local files and remote files that is stored in K/V Store of a consul cluster.
OPTIONS:
--addr 'localhost:8500' consul HTTP API address with port
--dc 'dc1' consul datacenter, uses local if blank
--prefix 'fileconsul' reading file status from Consul's K/V store with the given prefix
--basepath '.' base directory path of target files
Run fileconsul pull -h
to see the usage help:
$ fileconsul pull -h
NAME:
pull - Pull files from a consul cluster
USAGE:
command pull [command options] [arguments...]
DESCRIPTION:
Pull remote files from K/V Store of a consul cluster.
OPTIONS:
--addr 'localhost:8500' consul HTTP API address with port
--dc 'dc1' consul datacenter, uses local if blank
--prefix 'fileconsul' reading file status from Consul's K/V store with the given prefix
--basepath '.' base directory path of target files
Run fileconsul push -h
to see the usage help:
$ fileconsul push -h
NAME:
push - Push file to a consul cluster
USAGE:
command push [command options] [arguments...]
DESCRIPTION:
Push remote files to K/V Store of a consul cluster.
OPTIONS:
--addr 'localhost:8500' consul HTTP API address with port
--dc 'dc1' consul datacenter, uses local if blank
--prefix 'fileconsul' reading file status from Consul's K/V store with the given prefix
--basepath '.' base directory path of target files
Use the demo environment for fileconsul
$ git clone https://github.com/foostan/fileconsul.git
$ cd fileconsul/demo
$ docker build -t fileconsul .
$ docker run -h server -i -t fileconsul
root@server:/# consul agent -data-dir=/tmp/consul -server -bootstrap-expect 1 &
==> WARNING: BootstrapExpect Mode is specified as 1; this is the same as Bootstrap mode.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> WARNING: It is highly recommended to set GOMAXPROCS higher than 1
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
Node name: 'server'
Datacenter: 'dc1'
Server: true (bootstrap: true)
Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400)
Cluster Addr: 172.17.0.6 (LAN: 8301, WAN: 8302)
Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
--- omitted below ---
$ docker run -h client -i -t fileconsul
root@client:/# consul agent -data-dir=/tmp/consul -join 172.17.0.6 &
==> WARNING: It is highly recommended to set GOMAXPROCS higher than 1
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Joining cluster...
Join completed. Synced with 1 initial agents
==> Consul agent running!
Node name: 'client'
Datacenter: 'dc1'
Server: false (bootstrap: false)
Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400)
Cluster Addr: 172.17.0.5 (LAN: 8301, WAN: 8302)
Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
--- omitted below ---
root@server:/# cd /consul/share/
root@server:/consul/share# fileconsul status
Changes to be pushed:
(use "fileconsul push [command options]" to synchronize local files)
add remote file: bin/ntp
add remote file: bin/apache2
add remote file: bin/loadavg
add remote file: config/service/apache2.json
add remote file: config/service/ntp.json
add remote file: config/template/server/check_loadavg.json
add remote file: config/template/server/service_apache2.json
add remote file: config/template/server/agent_server.json
add remote file: config/template/server/service_ntp.json
add remote file: config/template/client/check_loadavg.json
add remote file: config/template/client/agent_client.json
add remote file: config/template/client/service_ntp.json
add remote file: config/check/loadavg.json
root@server:/consul/share# fileconsul push
push new file: bin/ntp
push new file: bin/apache2
push new file: bin/loadavg
push new file: config/service/apache2.json
push new file: config/service/ntp.json
push new file: config/template/server/check_loadavg.json
push new file: config/template/server/service_apache2.json
push new file: config/template/server/agent_server.json
push new file: config/template/server/service_ntp.json
push new file: config/template/client/check_loadavg.json
push new file: config/template/client/agent_client.json
push new file: config/template/client/service_ntp.json
push new file: config/check/loadavg.json
root@server:/# cd /consul/share/
root@client:/consul/share# vi bin/apache2 # edit a file
root@client:/consul/share# fileconsul status
Changes to be pushed:
(use "fileconsul push [command options]" to synchronize local files)
modify remote file: bin/apache2
Changes to be pulled:
(use "fileconsul pull [command options]" to synchronize remote files)
modify local file: bin/apache2
root@client:/consul/share# fileconsul push
push modified file: bin/apache2
root@server:/consul/share# fileconsul status
Changes to be pushed:
(use "fileconsul push [command options]" to synchronize local files)
modify remote file: bin/apache2
Changes to be pulled:
(use "fileconsul pull [command options]" to synchronize remote files)
modify local file: bin/apache2
root@server:/consul/share# fileconsul pull
Synchronize remote files:
modified: bin/apache2
Already up-to-date.
- Fork it ( https://github.com/[my-github-username]/fileconsul/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request