Ubuntu 16.04, chef-client version 12.21.12
My receipt
apt_package 'influxdb' do
version '1.3.5-1'
end
template '/etc/influxdb/influxdb.conf' do
source 'config_influxdb.erb'
owner 'root'
group 'root'
mode '0644'
notifies :restart, "service[influxdb]", :immediately
end
bash 'create admin user' do
code <<-EOH
influx --execute "CREATE USER "admin" WITH PASSWORD 'mysuperpass' WITH ALL PRIVILEGES"
echo "influxdb admin user created" > /opt/chef/run_once_tag
EOH
not_if { ::File.exists?("/opt/chef/run_once_tag") }
end
I get error
INFO: template[/etc/influxdb/influxdb.conf] sending restart action to service[influxdb] (immediate)
service[influxdb] action restart[2017-09-20T14:24:45+00:00] INFO: Processing service[influxdb] action restart (influxdata::default line 76)
INFO: service[influxdb] restarted
[execute] Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp [::1]:8086: getsockopt: connection refused
Please check your connection settings and ensure 'influxd' is running.
So it looks like influxdb service is restarted before running bash resource with CREATE USER but it doesn't really.
If I run chef-client second time service is already started and bash resource runs successfully.
I tried to add
execute "systemctl start influxdb" do
end
before bash resource but it doesn't fix the problem.