Git Product home page Git Product logo

chef-consul-template's People

Contributors

adamkrone avatar anoldguy avatar anuriq avatar atongen avatar ccannell67 avatar csghuser avatar deltaroe avatar franklinwise avatar gamepoet avatar inean avatar legal90 avatar logankoester avatar miguelv-dev avatar mrcroy avatar robx avatar scalp42 avatar seanb4t avatar swalberg avatar tgwizard avatar tiwilliam avatar ton31337 avatar xmik 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-consul-template's Issues

Updating version does not update the binary

Upgrading does not appear to be upgrading the binary:

default['consul_template']['version'] = '0.12.0'
default['consul_template']['checksums']['consul-template_0.12.0_linux_amd64'] = '1fff23fa44fd0af0cb56f011a911af1e9d407a2eeb360f520a503d2f330fdf43'
Recipe: consul-template::install_binary
  * ark[consul-template] action cherry_pick
    * directory[/usr/local/bin] action create (up to date)
    * remote_file[/var/chef/cache/consul-template.zip] action create
      - create new file /var/chef/cache/consul-template.zip
      - update content in file /var/chef/cache/consul-template.zip from none to 1fff23
      (new content is binary, diff output suppressed)
    * execute[cherry_pick consul-template from /var/chef/cache/consul-template.zip] action nothing (skipped due to action :nothing)
    * execute[set owner on /usr/local/bin] action nothing (skipped due to action :nothing)
    * execute[cherry_pick consul-template from /var/chef/cache/consul-template.zip] action run (up to date)

  * file[/usr/local/bin/consul-template] action touch
    - update utime on file /usr/local/bin/consul-template
root@i-014fe1d8# consul-template --version
2015/12/18 02:05:07 [DEBUG] (logging) setting up logging
2015/12/18 02:05:07 [DEBUG] (logging) config:

{
  "name": "consul-template",
  "level": "WARN",
  "syslog": false,
  "syslog_facility": "LOCAL0"
}

consul-template v0.10.0

Cookbook is now longer compatible with Chef 11

The 0.10.0 release added issues_url and source_url lines to metadata.rb. Unfortunately, those are not present in Chef 11 and, as a result, the cookbook cannot be used in Chef 11. This can be fixed while retaining their functionality by adding if respond_to? guards, like so:

issues_url 'https://github.com/adamkrone/chef-consul-template/issues' if respond_to?(:issues_url)
source_url 'https://github.com/adamkrone/chef-consul-template' if respond_to?(:source_url)

Release 0.13.1 to fix windows support

I notice that there are commits in master which fix a syntax bug I've seen when converging this cookbook on Windows Sever machines, but these commits were made after the current 0.13.0 release:

would it be possible to release this as a 0.13.1 release to Chef Supermarket?

Remove libarchive::default recipe

Failing due to libarchive::default recipe

Installing Cookbook Gems:
Compiling Cookbooks...
[2018-05-07T18:58:06+00:00] WARN: The libarchive::default recipe is no longer needed and should not be included on runlists
Converging 10 resources
Recipe: consul-template::install_binary
* remote_file[/tmp/kitchen/cache/consul-template_0.19.4_linux_amd64.zip] action create_if_missing (up to date)
* archive_file[consul-template_0.19.4_linux_amd64.zip] action extract
- create directory /opt/consul-template/consul-template_0.19.4_linux_amd64
Running handlers:
[2018-05-07T18:58:06+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-05-07T18:58:06+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 04 seconds
[2018-05-07T18:58:06+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-05-07T18:58:06+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-05-07T18:58:06+00:00] FATAL: LoadError: Could not open library 'archive': archive: cannot open shared object file: No such file or directory.
Could not open library 'libarchive.so': /lib64/liblzma.so.5: version `XZ_5.2' not found (required by /opt/chef/embedded/lib/libarchive.so).
Could not open library 'libarchive.so.2': libarchive.so.2: cannot open shared object file: No such file or directory

Syntax error in libraries/consul-template-helpers

I got this error:
amazon-ebs: SyntaxError
    amazon-ebs: -----------
    amazon-ebs: /tmp/packer-chef-solo/cookbooks-1/consul-template/libraries/consul-template_helpers.rb:32: syntax error, unexpected '.'

here's the line of code in question:
path&.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\')

This was running on a linux box I believe.

How to test notification in ChefSpec?

Thanks for making this open source. I'm using this cookbook to setup consul-template for our nginx load balancing.

It works great, but I have a problem trying to test notification of reload using ChefSpec

Here is my consul_template_config definition

consul_template_config service_name do
  templates [{
    source: '/etc/nginx/nginx.conf.ctmpl',
    destination: '/etc/nginx/nginx.conf',
    command: 'service nginx reload'
  }]
  notifies :reload, 'service[consul-template]', :delayed
end

And here is my ChefSpec test

    consul_template = chef_run.consul_template_config(service_name)
    expect(consul_template).to notify('service[consul-template]')
      .to(:reload).delayed

But I get

     Failure/Error: consul_template = chef_run.consul_template_config(service_name)

     NoMethodError:
       undefined method `consul_template_config' for #<ChefSpec::SoloRunner:0x007fcf5ffbf5f0>

Am I doing something wrong?

Can't install consul-template

Trying to install consul-template into docker debian:jessie.
Version 0.14.0 works fine. But now I need >= 0.18.0, and it doesn't work.

My node json docker-consul-template.json:

{
  "consul_template" : {
    "version" : "0.19.0",
    "checksums": {
      "consul-template_0.19.0_linux_amd64": "31dda6ebc7bd7712598c6ac0337ce8fd8c533229887bd58e825757af879c5f9f"
    }
  },
  "run_list": [
    "recipe[consul-template]",
    "recipe[rubber::consul-template]"
  ],
  "automatic": {
    "ipaddress": "localhost"
  }
}

at "recipe[rubber::consul-template]" right now commented everything

Error:

:install_binary line 20)
[2017-08-21T16:38:02+00:00] INFO: remote_file[/chef/local-mode-cache/cache/consul-template_0.19.0_linux_amd64.zip] created file /chef/local-mode-cache/cache/consul-template_0.19.0_linux_amd64.zip
[2017-08-21T16:38:02+00:00] INFO: remote_file[/chef/local-mode-cache/cache/consul-template_0.19.0_linux_amd64.zip] updated file contents /chef/local-mode-cache/cache/consul-template_0.19.0_linux_amd64.zip
[2017-08-21T16:38:02+00:00] INFO: Processing libarchive_file[consul-template_0.19.0_linux_amd64.zip] action extract (consul-template::install_binary line 26)
[2017-08-21T16:38:02+00:00] INFO: libarchive_file[consul-template_0.19.0_linux_amd64.zip] extracting /chef/local-mode-cache/cache/consul-template_0.19.0_linux_amd64.zip to /usr/local/bin/consul-template_0.19.0_linux_amd64
[2017-08-21T16:38:02+00:00] INFO: Processing link[/usr/local/bin/consul-template] action create (consul-template::install_binary line 34)
[2017-08-21T16:38:02+00:00] INFO: link[/usr/local/bin/consul-template] created
[2017-08-21T16:38:02+00:00] WARN: /usr/local/bin/consul-template mode not changed: File.lchmod is unimplemented on this OS and Ruby version
[2017-08-21T16:38:02+00:00] INFO: link[/usr/local/bin/consul-template] mode changed to 755
[2017-08-21T16:38:02+00:00] INFO: Processing linux_user[root] action create (consul-template::service line 33)
[2017-08-21T16:38:02+00:00] INFO: Processing group[root] action create (consul-template::service line 41)
[2017-08-21T16:38:02+00:00] INFO: Processing directory[/etc/consul-template.d] action create (consul-template::service line 49)
[2017-08-21T16:38:02+00:00] INFO: directory[/etc/consul-template.d] created directory /etc/consul-template.d
[2017-08-21T16:38:02+00:00] INFO: directory[/etc/consul-template.d] owner changed to 0
[2017-08-21T16:38:02+00:00] INFO: directory[/etc/consul-template.d] group changed to 0
[2017-08-21T16:38:02+00:00] INFO: directory[/etc/consul-template.d] mode changed to 755
[2017-08-21T16:38:02+00:00] INFO: Processing file[/etc/consul-template.d/default.json] action create (consul-template::service line 58)
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] created file /etc/consul-template.d/default.json
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] updated file contents /etc/consul-template.d/default.json
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] owner changed to 0
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] group changed to 0
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] mode changed to 600
[2017-08-21T16:38:02+00:00] INFO: file[/etc/consul-template.d/default.json] not queuing delayed action restart on service[consul-template] (delayed), as it's already been queued
[2017-08-21T16:38:02+00:00] INFO: Processing template[/etc/init.d/consul-template] action create (consul-template::service line 85)
[2017-08-21T16:38:02+00:00] INFO: template[/etc/init.d/consul-template] created file /etc/init.d/consul-template
[2017-08-21T16:38:02+00:00] INFO: template[/etc/init.d/consul-template] updated file contents /etc/init.d/consul-template
[2017-08-21T16:38:02+00:00] INFO: template[/etc/init.d/consul-template] mode changed to 755
[2017-08-21T16:38:02+00:00] INFO: template[/etc/init.d/consul-template] sending restart action to service[consul-template] (immediate)
[2017-08-21T16:38:02+00:00] INFO: Processing service[consul-template] action restart (consul-template::service line 98)
[2017-08-21T16:38:02+00:00] INFO: service[consul-template] restarted
[2017-08-21T16:38:02+00:00] INFO: Processing service[consul-template] action enable (consul-template::service line 98)
[2017-08-21T16:38:02+00:00] INFO: service[consul-template] enabled
[2017-08-21T16:38:02+00:00] INFO: Processing service[consul-template] action start (consul-template::service line 98)
[2017-08-21T16:38:02+00:00] INFO: libarchive_file[consul-template_0.19.0_linux_amd64.zip] sending restart action to service[consul-template] (delayed)
[2017-08-21T16:38:02+00:00] INFO: Processing service[consul-template] action restart (consul-template::service line 98)

================================================================================
Error executing action `restart` on resource 'service[consul-template]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/consul-template restart ----
STDOUT: Stopping consul-template.............
consul-template not stopped; may still be shutting down or shutdown may have failed
Unable to stop consul-template, will not attempt to start
STDERR: 
---- End output of /etc/init.d/consul-template restart ----
Ran /etc/init.d/consul-template restart returned 1

Resource Declaration:
---------------------
# In /chef/local-mode-cache/cache/cookbooks/consul-template/recipes/service.rb

 98:   service 'consul-template' do
 99:     provider Chef::Provider::Service::Upstart if is_upstart
100:     supports status: true, restart: true, reload: true
101:     action [:enable, :start]
102:     subscribes :restart, "libarchive_file[#{ConsulTemplateHelpers.install_file(node)}]", :delayed
103:   end
104: 

Compiled Resource:
------------------
# Declared in /chef/local-mode-cache/cache/cookbooks/consul-template/recipes/service.rb:98:in `from_file'

service("consul-template") do
  action [:enable, :start]
  updated true
  supports {:status=>true, :restart=>true, :reload=>true}
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  service_name "consul-template"
  enabled true
  running true
  masked nil
  pattern "consul-template"
  declared_type :service
  cookbook_name "consul-template"
  recipe_name "service"
end

Platform:
---------
x86_64-linux

[2017-08-21T16:38:13+00:00] ERROR: Running exception handlers
[2017-08-21T16:38:13+00:00] ERROR: Exception handlers complete
[2017-08-21T16:38:13+00:00] FATAL: Stacktrace dumped to /chef/local-mode-cache/cache/chef-stacktrace.out
[2017-08-21T16:38:13+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-08-21T16:38:13+00:00] ERROR: service[consul-template] (consul-template::service line 98) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/consul-template restart ----
STDOUT: Stopping consul-template.............
consul-template not stopped; may still be shutting down or shutdown may have failed
Unable to stop consul-template, will not attempt to start
STDERR: 
---- End output of /etc/init.d/consul-template restart ----
Ran /etc/init.d/consul-template restart returned 1
[2017-08-21T16:38:13+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Update to not pull in the Supervisor cookbook

The Supervisor cookbook depends on the deprecated Python cookbook so indirectly the consul-template cookbook depends on the Python cookbook but I'm pretty sure it doesn't need python.

Config dir permissions are getting double-set

There are two places in the cookbook that are creating the config dir, and they're setting different permissions...

In the service recipe:

# Create service directories
consul_template_directories.each do |dirname|
directory dirname do
owner consul_template_user
group consul_template_group
mode 0755
end
end

In the config provider:

# Ensure config directory exists
directory node['consul_template']['config_dir'] do
user consul_template_user
group consul_template_group
mode node['consul_template']['template_mode']
recursive true
action :create
end

I'm guessing that the 0755 that the service recipe sets is probably correct for the directory, and that the config provider should be using that (and just using node['consul_template']['template_mode'] for the template config file). As it is now, the config resource is always setting its changed flag, which is causing our wrapper template to restart consul-template unnecessarily.

systemd config times out on service stop/restart on ubuntu 16.04

The current systemd template fails to cleanly stop (or restart) the CT service on Ubuntu 16.04:

May 24 00:58:41 vagrant-vbox-1 systemd[1]: Stopping Consul Template Daemon...
May 24 00:58:41 vagrant-vbox-1 consul-template[8488]: 2017/05/24 00:58:41.853612 [DEBUG] (cli) receiving signal "terminated"
May 24 00:58:41 vagrant-vbox-1 consul-template[8488]: 2017/05/24 00:58:41.853624 [DEBUG] (cli) receiving signal "continued"
May 24 01:00:12 vagrant-vbox-1 systemd[1]: consul-template.service: State 'stop-sigterm' timed out. Killing.
May 24 01:00:12 vagrant-vbox-1 systemd[1]: consul-template.service: Main process exited, code=killed, status=9/KILL
May 24 01:00:12 vagrant-vbox-1 systemd[1]: Stopped Consul Template Daemon.

It looks like adding a ExecStop line in consul-template-systemd.erb solves this issue.

ExecStop=/bin/kill -INT $MAINPID

Ideally the signal would be tied back to the kill_signal config.

Happy to submit a PR if that helps.

expand consul_template_config to allow contents instead of source

This will allow avoiding template files when they are very trivial.

From CT config:

# This option allows embedding the contents of a template in the configuration
# file rather then supplying the `source` path to the template file. This is
# useful for short templates. This option is mutually exclusive with the
# `source` option.

Right now if source is missing the resource throws an error.

Unit consul-template.service entered failed state, exit code=14

The cookbook runs successfully, but the service enters failed state:

$ sudo service consul-template status
Redirecting to /bin/systemctl status  consul-template.service
● consul-template.service - Consul Template Daemon
   Loaded: loaded (/etc/systemd/system/consul-template.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Mon 2018-02-19 09:14:52 UTC; 35s ago
  Process: 26129 ExecStart=/usr/local/bin/consul-template -config /etc/consul-template.d (code=exited, status=14)
 Main PID: 26129 (code=exited, status=14)

In case I manually run the comand /usr/local/bin/consul-template -config /etc/consul-template.d or service consul-template restart it perfectly works.


OS Centos: 7.3.1611
The cookbook version: 0.12.0
Chef-client: 12.20.3
consul-template: 0.19.4

$ sudo cat /etc/systemd/system/consul-template.service
[Unit]
Description=Consul Template Daemon
Wants=basic.target
After=basic.target network.target

[Service]
User=consul-template
Group=consul-template
ExecStart=/usr/local/bin/consul-template -config /etc/consul-template.d
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

$ sudo cat /etc/consul-template.d/default.json
{
}


$ sudo cat /etc/consul-template.d/haproxy

template {
  source = "/etc/haproxy/haproxy.cfg.ctmpl"
  destination = "/etc/haproxy/haproxy.cfg"

  command = "/bin/bash -c 'systemctl restart haproxy || true'"






}

/usr/local/bin/consul-template is created as a zero-length file

When:

  • the /usr/local/bin/consul-template file does not exist
  • the /var/chef/cache/consul-template.zip file exists

Then running chef-client will result in the /usr/local/bin/consul-template being created as a zero-length file (and of course, the service[consul-template] will not be running at the end of the chef-run).

This condition is easy to reproduce, just type rm /usr/local/bin/consul-template on existing setup before running chef-client again.

Here is the relevant portion of my chef-client log (with my comments added):

Recipe: consul-template::install_binary
  * ark[consul-template] action cherry_pick
    * directory[/usr/local/bin] action create (up to date)
    * remote_file[/var/chef/cache/consul-template.zip] action create (up to date)
    * execute[cherry_pick consul-template from /var/chef/cache/consul-template.zip] action nothing (skipped due to action :nothing)   # <<<<---- this skips extracting consul-template.zip, so /usr/local/bin/consul-template is not created
    * execute[set owner on /usr/local/bin] action nothing (skipped due to action :nothing)
     (up to date)
  * file[/usr/local/bin/consul-template] action touch  # <<<<--- this creates the file as a zero-length file
    - create new file /usr/local/bin/consul-template
    - change mode from '' to '0755' 
    - update utime on file /usr/local/bin/consul-template

The archive should be extracted in all cases when /usr/local/bin/consul-template does not exist.

mark default.json file resource as sensitive

Since the config has can include tokens for consul and vault, it would suggest marking the resource creating the file as sensitive to prevent leaking this info to chef logs.

Current tagged release v0.9.1 is broken for new consul-template v0.12.2

Hello,
i have spotted an error while calling this cookbook inside my wrapper cookbook which took me a while to debug. I have been getting the following key error due to a wrong filename search for it's own checksum. The recipe should be searching for the checksum named 'consul-template...' (with a dash in the middle) but instead it's searching 'consul_template...' (with an underscore) which causes it to throw a key not found error.

key not found: "consul_template_0.12.2_linux_amd64" 

After a bit of debugging and trying out this cookbook on itself I released that the fix has already been implemented in the master branch but it hasn't been released yet, hence still erroring when calling this via a wrapper cookbook.

Could you please create a new tagged release so that I can call this cookbook successfully?
Thank you

nssm_params cause master branch recipe to fail to compile

       ================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/consul-template/attributes/default.rb
       ================================================================================

       NoMethodError
       -------------
       Undefined method or attribute `data_path' on `node'

       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/consul-template/attributes/default.rb:33:in `from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/consul-template/attributes/default.rb:

        26:  default['consul_template']['template_mode'] = 0600
        27:
        28:  # Config attributes
        29:  default['consul_template']['config'] = Hash.new
        30:
        31:  # Windows only
        32:  default['consul_template']['nssm_params'] = {
        33>>   'AppDirectory'     => data_path,
        34:    'AppStdout'        => join_path(config_prefix_path, 'stdout.log'),
        35:    'AppStderr'        => join_path(config_prefix_path, 'error.log'),
        36:    'AppRotateFiles'   => 1,
        37:    'AppRotateOnline'  => 1,
        38:    'AppRotateBytes'   => 20_000_000
        39:  }
        40:

       Platform:
       ---------
       x86_64-linux

broken compatibility with Chef 12

commit 5c957f7 broke compatibility with Chef 12's ruby version by modifying libraries/consul-template_helpers.rb line 25 to use the new .match? method.

I see someone already opened PR 81 which would fix this issue. Thanks!

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.