{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/436","labels_url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/436/labels{/name}","comments_url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/436/comments","events_url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/436/events","html_url":"https://github.com/elastic/puppet-elasticsearch/pull/436","id":102977712,"number":436,"title":"Require the config before starting the service","user":{"login":"stevenpost","id":3898020,"avatar_url":"https://avatars.githubusercontent.com/u/3898020?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenpost","html_url":"https://github.com/stevenpost","followers_url":"https://api.github.com/users/stevenpost/followers","following_url":"https://api.github.com/users/stevenpost/following{/other_user}","gists_url":"https://api.github.com/users/stevenpost/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenpost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenpost/subscriptions","organizations_url":"https://api.github.com/users/stevenpost/orgs","repos_url":"https://api.github.com/users/stevenpost/repos","events_url":"https://api.github.com/users/stevenpost/events{/privacy}","received_events_url":"https://api.github.com/users/stevenpost/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-25T08:43:56Z","updated_at":"2015-08-25T11:04:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elastic/puppet-elasticsearch/pulls/436","html_url":"https://github.com/elastic/puppet-elasticsearch/pull/436","diff_url":"https://github.com/elastic/puppet-elasticsearch/pull/436.diff","patch_url":"https://github.com/elastic/puppet-elasticsearch/pull/436.patch"},"body":"Hi,\r\n\r\nThis PR fixes an issue only seen with restart_on_change => true.\r\nDue to the missing requires, Puppet sometimes tries to start the service before setting the config of the instance, resulting in a failure. This isn't seen in the default configuration because the notify wiil force the service to be delayed till after the (re)start.\r\n\r\nNote that I am unable to run the test suite as the following command returns an error:\r\n$ bundle install --path vendor/bundle\r\n...\r\nGem::InstallError: i18n requires Ruby version >= 1.9.3.\r\nAn error occurred while installing i18n (0.7.0), and Bundler cannot continue.\r\nMake sure that `gem install i18n -v '0.7.0'` succeeds before bundling.\r\n\r\nRegards,\r\nSteven"},"comment":{"url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/comments/134555328","html_url":"https://github.com/elastic/puppet-elasticsearch/pull/436#issuecomment-134555328","issue_url":"https://api.github.com/repos/elastic/puppet-elasticsearch/issues/436","id":134555328,"user":{"login":"stevenpost","id":3898020,"avatar_url":"https://avatars.githubusercontent.com/u/3898020?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenpost","html_url":"https://github.com/stevenpost","followers_url":"https://api.github.com/users/stevenpost/followers","following_url":"https://api.github.com/users/stevenpost/following{/other_user}","gists_url":"https://api.github.com/users/stevenpost/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenpost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenpost/subscriptions","organizations_url":"https://api.github.com/users/stevenpost/orgs","repos_url":"https://api.github.com/users/stevenpost/repos","events_url":"https://api.github.com/users/stevenpost/events{/privacy}","received_events_url":"https://api.github.com/users/stevenpost/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T11:04:05Z","updated_at":"2015-08-25T11:04:05Z","body":"I'll paste the relevant code below, but you might get a better proof by studying the generated graphs when running with puppet 'agent --test --graph'.\r\nYou can use 'zgrviewer' [1] which has a search function (works on multiple OSes, written in Java).\r\nThe resources are executed in a mostly random order when running Puppet, so you might not notice it at first. I noticed it because the service tried to start (and failed) before the config was written.\r\nYou'll see in the 'relationships.dot' that the resource 'File[/etc/elasticsearch/elkcl2/elasticsearch.yml]' has dependencies (parent directories, the Class[Elasticsearch::Package] resource, its user and group) but no dependants whatsoever (like the service).\r\n\r\n[1] http://zvtm.sourceforge.net/zgrviewer.html\r\n\r\n```\r\n  class { '::profile::elasticsearch':\r\n    cluster_name    => 'elkcl2',\r\n    heap_size       => '8G',\r\n    instance_config => {\r\n      'bootstrap.mlockall'                   => 'true',\r\n      'cluster.name'                         => 'elkcl2',\r\n      'node.max_local_storage_nodes'         => '1',\r\n      'index.number_of_replicas'             => '0',\r\n      'index.number_of_shards'               => '1',\r\n      'network.publish_host'                 => $::fqdn,\r\n      'discovery.zen.ping.multicast.enabled' => 'false',\r\n      'discovery.zen.ping.unicast.hosts'     => \"[\\\"${::fqdn}\\\"]\",\r\n      'action'                               => {\r\n        'disable_delete_all_indices' => 'true',\r\n        'destructive_requires_name'  => 'true',\r\n        'disable_shutdown'           => 'true',\r\n      },\r\n      'script.disable_dynamic'               => 'false',\r\n    },\r\n  }\r\n\r\nclass profile::elasticsearch (\r\n  $cluster_name,\r\n  $heap_size,\r\n  $instance_config,\r\n) {\r\n\r\n  # create the elasticsearch group with a specific GID.\r\n  group { 'elasticsearch':\r\n    ensure => present,\r\n    gid    => 1499,\r\n  }\r\n\r\n  user { 'elasticsearch':\r\n    ensure     => present,\r\n    uid        => 1499,\r\n    gid        => 1499,\r\n    shell      => '/bin/bash',\r\n    home       => '/usr/share/elasticsearch',\r\n    managehome => true,\r\n    require    => Group['elasticsearch'],\r\n  }\r\n\r\n  file { '/usr/share/elasticsearch/.profile':\r\n    ensure  => 'present',\r\n    mode    => '0664',\r\n    owner   => 'elasticsearch',\r\n    group   => 'elasticsearch',\r\n    source  => 'puppet:///modules/profile/elasticsearch/profile',\r\n    require => User['elasticsearch'],\r\n  }\r\n\r\n  $_es_dirs = ['/var/app/elasticsearch', '/var/app/elasticsearch/logs', '/var/app/elasticsearch/bin']\r\n  file { $_es_dirs :\r\n    ensure => 'directory',\r\n    owner  => 'elasticsearch',\r\n    group  => 'elasticsearch',\r\n    mode   => '0664',\r\n  }\r\n  ->\r\n  # version lock via hiera\r\n  class { '::elasticsearch':\r\n    datadir           => '/var/app/elasticsearch/data',\r\n    restart_on_change => false,\r\n    require           => User['elasticsearch'],\r\n  }\r\n\r\n  elasticsearch::instance { $cluster_name :\r\n    config        => $instance_config,\r\n    init_defaults => {\r\n      'ES_HEAP_SIZE'   => $heap_size,\r\n      'MAX_OPEN_FILES' => '65535',\r\n      'MAX_MAP_COUNT'  => '262144',\r\n      'LOG_DIR'        => \"/var/app/elasticsearch/logs/${cluster_name}\",\r\n    },\r\n  }\r\n\r\n  file { '/var/app/elasticsearch/bin/elasticsearch-remove-old-indices.sh':\r\n    content => template('roles/elk/elasticsearch-remove-old-indices.sh.erb'),\r\n    owner   => 'elasticsearch',\r\n    group   => 'elasticsearch',\r\n    mode    => '0744',\r\n  }\r\n\r\n  elasticsearch::plugin { 'elasticsearch/marvel/1.3.1':\r\n    instances => $cluster_name,\r\n  }\r\n  elasticsearch::plugin { 'mobz/elasticsearch-head':\r\n    instances => $cluster_name,\r\n  }\r\n  elasticsearch::plugin { 'lmenezes/elasticsearch-kopf':\r\n    instances => $cluster_name,\r\n  }\r\n  elasticsearch::plugin { 'lukas-vlcek/bigdesk':\r\n    instances => $cluster_name,\r\n  }\r\n  elasticsearch::plugin { 'royrusso/elasticsearch-HQ':\r\n    instances => $cluster_name,\r\n  }\r\n\r\n}\r\n```"}}