GithubHelp home page GithubHelp logo

consul-rpm's Introduction

RPM Spec for Consul

Tries to follow the packaging guidelines from Fedora.

  • Binary: /usr/bin/consul
  • Config: /etc/consul.d/
  • Shared state: /var/lib/consul/
  • Sysconfig: /etc/sysconfig/consul
  • WebUI: /usr/share/consul/

Using

Create the RPMs using one of the techniques outlined in the Build section below.

Pre-built packages

Pre-built packages are maintained via the Fedora Copr system. For more information, please see the duritong/consul repository on Copr.

Build

There are a number of ways to build the consul and consul-ui RPMs:

  • Manual
  • Vagrant
  • Docker

Each method ultimately does the same thing - pick the one that is most comfortable for you.

Version

The version number is hardcoded into the SPEC, however should you so choose, it can be set explicitly by passing an argument to rpmbuild directly:

$ rpmbuild --define "_version 0.6.3"

Manual

Build the RPM as a non-root user from your home directory:

  • Check out this repo. Seriously - check it out. Nice.

    git clone <this_repo_url>
    
  • Install rpmdevtools and mock.

    sudo yum install rpmdevtools mock
    
  • Set up your rpmbuild directory tree.

    rpmdev-setuptree
    
  • Link the spec file and sources.

    ln -s $HOME/consul-rpm/SPECS/consul.spec $HOME/rpmbuild/SPECS/
    find $HOME/consul-rpm/SOURCES -type f -exec ln -s {} $HOME/rpmbuild/SOURCES/ \;
    
  • Download remote source files.

    spectool -g -R rpmbuild/SPECS/consul.spec
    
  • Spectool may fail if your distribution has an older version of cURL (CentOS 6.x, for example) - if so, use Wget instead.

    VER=`grep Version rpmbuild/SPECS/consul.spec | awk '{print $2}'`
    URL='https://dl.bintray.com/mitchellh/consul'
    wget $URL/consul_${VER}_linux_amd64.zip -O $HOME/rpmbuild/SOURCES/consul_${VER}_linux_amd64.zip
    wget $URL/consul_${VER}_web_ui.zip -O $HOME/rpmbuild/SOURCES/consul_${VER}_web_ui.zip
    
  • Build the RPM.

    rpmbuild -ba rpmbuild/SPECS/consul.spec
    

Vagrant

If you have Vagrant installed:

  • Check out this repo.

    git clone https://github.com/tomhillable/consul-rpm
    
  • Edit Vagrantfile to point to your favourite box (Bento CentOS7 in this example).

    config.vm.box = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.0_chef-provisionerless.box"
    
  • Vagrant up! The RPMs will be copied to working directory after provisioning.

    vagrant up
    

Docker

If you prefer building it with Docker:

Manually

  • Build the Docker image. Note that you must amend the Dockerfile header if you want a specific OS build (centos6 and centos7 are currently included).

    docker build -t consul:build ./docker/centos7/
    
  • Run the build.

    docker run -v $HOME/consul-rpms:/RPMS consul:build
    
  • Retrieve the built RPMs from $HOME/consul-rpms.

Docker compose

Alternatively, there is a docker compose file included with this repo that automates the process of building the Docker image and running commands.

  • Build with:

    docker-compose run <centos6|centos7>
  • Retrieve build rpms from ./RPMS.

Currently, the docker-compose services can be either centos6 or centos7 for each respective OS version.

Result

Three RPMs:

  • consul server
  • consul web UI
  • consul-template

Run

  • Install the RPM.
  • Put config files in /etc/consul.d/.
  • Change command line arguments to consul in /etc/sysconfig/consul.
    • Add -bootstrap only if this is the first server and instance.
  • Start the service and tail the logs systemctl start consul.service and journalctl -f.
    • To enable at reboot systemctl enable consul.service.
  • Consul may complain about the GOMAXPROCS setting. This is safe to ignore; however, the warning can be supressed by uncommenting the appropriate line in /etc/sysconfig/consul.

Config

Config files are loaded in lexicographical order from the config-dir. Some sample configs are provided.

More info

See the consul.io website.

Backwards compatibility

Earlier verisons of this package used /etc/consul/ as the default configuration directory. As of 0.7.2, the default directory was changed to /etc/consul.d/ in order to align with the offcial Consul docuemntation. In order to avoid breaking existing installations during upgrade, both of the directories will be created during package install.

consul-rpm's People

Contributors

ambakshi avatar arodd avatar dky avatar duritong avatar edgej avatar epleterte avatar grossws avatar ivoronin avatar jasperla avatar koreanbbque avatar lebriquet avatar leeuwenrjj avatar millnert avatar nathanhruby avatar patsevanton avatar pdilung avatar phrawzty avatar rumenvasilev avatar temikus avatar tomhillable avatar tomlanyon avatar tootedom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

consul-rpm's Issues

Cloudflare redirects

Seems that cloudflare's redirects breaks spectool's ability to download the files from dl.bintray.com.

Had to do:

wget https://dl.bintray.com/mitchellh/consul/0.5.0_web_ui.zip -O ~/rpmbuild/SOURCES/0.5.0_web_ui.zip
wget https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip -O ~/rpmbuild/SOURCES/0.5.0_linux_amd64.zip

This was on a Centos 6.4 server

No License

Hi,

Any chance of adding a license to the project, just so we know where we stand when using it?

Many Thanks

consul.init has the port hardcoded in the Startup

If you change the consul port in the consul.json config the consul.init file will fail to startup because it is hardcoded.

if netstat -nptl | grep -q "^tcp.*:8500.*LISTEN \+${pid}\/${prog}"; then

Restrict executable permission

Hello,

Thanks for this great repo, cut some time on deploying consul on a number of machines.
Would it be ok for a pull request on having additional parameters for the build process?

As an example, it would help having the possibility to set consul binary file mod to 750 where the servers can be accessed by non sudoers.

Let me know if this change adheres to this repo's guidelines and if a pull request should be created.

Thanks,
Alex.

Duplicate unpack prompt breaks build

Hi,

It looks like there is an issue unpacking the consul zip file.
It tries to unpack the file twice which results in a prompt to overwrite the file:

rpmbuild -ba rpmbuild/SPECS/consul.spec

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Y6tjDv

  • umask 022
  • cd /root/rpmbuild/BUILD
  • cd /root/rpmbuild/BUILD
  • rm -rf consul-0.9.2
  • /usr/bin/mkdir -p consul-0.9.2
  • cd consul-0.9.2
  • /usr/bin/unzip -qq /root/rpmbuild/SOURCES/consul_0.9.2_linux_amd64.zip
  • STATUS=0
  • '[' 0 -ne 0 ']'
  • /usr/bin/unzip -qq /root/rpmbuild/SOURCES/consul_0.9.2_linux_amd64.zip
    replace consul? [y]es, [n]o, [A]ll, [N]one, [r]ename:

I experience this both with rpmbuild command as with docker build.
It looks like it will be fixed by removing the '-b 0' from the %prep section but I am not a specfile expert.
Also 0.9.2 is the current latest version

Wait should be implemented in start/stop functions in RHEL6 init script

Hi,

I've came across a problem that is likely related to startup/shutdown of consul in RHEL 6. Following are the details:

Version:

  • consul version: 0.5.2
  • consul-rpm version: 0.5.2-2.17.el6

Details:

  1. It often takes some time until port 8400 is fired up after consul has been started by daemon function.
  2. It often takes some time until consul shuts down when killed by killproc.

This leads to following errors:

  1. Refusal of connection to agent port 8400 when fired right after the startup.
  2. The service fails to start upon restart action because some ports are still bound.

Steps to reproduce:

  1. Refusal of connection to agent port 8400:

    # service consul start && echo '>>> trying to join after start'; consul join -rpc-addr=127.0.0.1:8400 <ip_addr>; echo '>>> trying to join after 2s sleep'; sleep 2; consul join -rpc-addr=127.0.0.1:8400 <ip_addr>
    Starting consul:                                           [  OK  ]
    >>> trying to join after start
    Error connecting to Consul agent: dial tcp 127.0.0.1:8400: connection refused
    >>> trying to join after 2s sleep
    Successfully joined cluster by contacting 1 nodes.
    
    # service consul start; netstat -nptl | grep '8400.*LISTEN' || echo "no listener on tcp 8400"; sleep 1 && netstat -nptl | grep '8400.*LISTEN'
    Starting consul:                                           [  OK  ]
    no listener on tcp 8400
    tcp        0      0 127.0.0.1:8400              0.0.0.0:*                   LISTEN      21187/consul
    
  2. The service fails to start upon restart action because some ports are still bound.

    # service consul restart; echo '>>> after restart' && netstat -nptl | grep consul; echo '>>> after 2s sleep'; sleep 2; netstat -nptl | grep consul; echo '>>> log output'; grep 'address already in use' /var/log/consul | tail -1; echo -n '>>> consul pid: '; pgrep consul || echo 'N/A'
    Shutting down consul:                                      [  OK  ]
    Starting consul:                                           [  OK  ]
    >>> after restart
    tcp        0      0 <host_ip>:8301              0.0.0.0:*                   LISTEN      22934/consul
    tcp        0      0 127.0.0.1:8400              0.0.0.0:*                   LISTEN      22934/consul
    tcp        0      0 127.0.0.1:8500              0.0.0.0:*                   LISTEN      22934/consul
    tcp        0      0 127.0.0.1:8600              0.0.0.0:*                   LISTEN      22934/consul
    >>> after 2s sleep
    >>> log output
    ==> Error starting agent: Failed to start Consul client: Failed to start lan serf: Failed to start TCP listener. Err: listen tcp <host_ip>:8301: bind: address already in use
    >>> consul pid: N/A
    

Unfortunately I haven't investigated this in RHEL 7, nor I've tried different consul versions yet, however I implemented wait in RHEL 6 init script in PR #25.

@duritong, @tomhillable: Would you please review and eventually merge?

Thanks.

Consul not starting

Hi,

I am trying to run this in server mode on centos7 with the following cmd options

CMD_OPTS="agent -server -bootstrap-expect 1 -config-dir=/etc/consul -data-dir=/var/lib/consul

I install the rpm, but the service doesn't start on boot, but will start when i manually start it. On boot, when i look at the status, it indicates it is dead. Have you tried the rpm in server mode?

Suggestion: Provide a logrotate file

Since we're logging the output of consul to a file, I think it would be convenient to add a logrotate file to the RPM and automatically add it to /etc/logrotate.d. Thoughts?

SELinux policy

Hi,

I've created a SELinux policy module for consul (and vault for that matter). If you are interested to use it in the RPM, I'd be happy to share!

-fuero

init script for consul-template is broken

prog name
wait check
starting service

sh -x /etc/init.d/consul-template start
+ netstat -nptl
+ grep -q '^tcp.*:8400.*LISTEN \+9873\/consul-template'
+ sleep 1
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
consul  6403 consul   15u  IPv4  32419      0t0  TCP 127.0.0.1:8400 (LISTEN)

infinite loop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.