sensu_ctl resource is always skipped
Closed this issue · 8 comments
Hi folks,
Using 0.1.0
, I noticed that the sensu_ctl
resource only runs once:
sensu_ctl 'sensu' do
action %i[install configure]
end
* sensu_ctl[sensu] action configure[2019-09-28T00:20:52+00:00] INFO: Processing sensu_ctl[sensu] action configure (wo-sensu::default line 22)
(up to date)
I see the sensuctl user list
there https://github.com/sensu/sensu-go-chef/blob/0.1.0/resources/ctl.rb#L63 but I don't think .error?
is working:
root@default-ubuntu-1804:~# sensuctl user list
Error: No API URL is defined. You can configure an API URL by running "sensuctl configure"
root@default-ubuntu-1804:~# echo $?
1
Any ideas?
Thanks!
UPDATE: I noticed that that sensuctl
config files don't actually get created either.
I just did it by hand 6 mins later (see time from Chef run):
root@default-ubuntu-1804:~# sensuctl configure
? Sensu Backend URL: http://127.0.0.1:8080
? Username: admin
? Password: *********
? Namespace: kitchen
? Preferred output format: tabular
root@default-ubuntu-1804:~# ll .config/sensu/sensuctl/
total 16
drwxr-xr-x 2 root root 4096 Sep 28 00:26 ./
drwxr-xr-x 3 root root 4096 Sep 28 00:26 ../
-rw-r--r-- 1 root root 764 Sep 28 00:26 cluster
-rw-r--r-- 1 root root 51 Sep 28 00:26 profile
EDIT: @majormoses updated linked code to use a permalink since the code referenced line number did not match what was on master.
Hmm I am able to reproduce this from a quick test from master:
# cleanup
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen destroy default-ubuntu-1804
-----> Starting Kitchen (v1.21.2)
-----> Destroying <default-ubuntu-1804>...
Deleting kitchen sandbox at /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Deleting verifier sandbox at /home/babrams/.dokken/verifier_sandbox/c488ee9495-default-ubuntu-1804
Finished destroying <default-ubuntu-1804> (0m10.74s).
-----> Kitchen is finished. (0m11.85s)
# converge
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen converge default-ubuntu-1804
-----> Starting Kitchen (v1.21.2)
-----> Creating <default-ubuntu-1804>...
Creating kitchen sandbox at /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Creating verifier sandbox at /home/babrams/.dokken/verifier_sandbox/c488ee9495-default-ubuntu-1804
Building work image..
Creating container c488ee9495-default-ubuntu-1804
Finished creating <default-ubuntu-1804> (0m2.07s).
-----> Converging <default-ubuntu-1804>...
Creating kitchen sandbox in /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 7.0.4...
Removing non-cookbook files before transfer
Preparing data_bags
Preparing validation.pem
Preparing client.rb
Starting Chef Client, version 14.5.0
Creating a new client identity for default-ubuntu-1804 using the validator key.
resolving cookbooks for run list: ["sensu_test::default"]
Synchronizing Cookbooks:
- sensu_test (0.0.1)
- sensu-go (0.1.0)
- packagecloud (1.0.0)
- seven_zip (3.1.2)
- windows (6.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 21 resources
Recipe: sensu_test::default
* sensu_backend[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create
- create new file /etc/apt/sources.list.d/sensu_stable.list
- update content in file /etc/apt/sources.list.d/sensu_stable.list from none to 0c5ca9
--- /etc/apt/sources.list.d/sensu_stable.list 2019-10-26 02:03:15.136696162 +0000
+++ /etc/apt/sources.list.d/.chef-sensu_stable20191026-62-1inwhgu.list 2019-10-26 02:03:15.136696162 +0000
@@ -1 +1,3 @@
+deb https://packagecloud.io/sensu/stable/ubuntu bionic main
+deb-src https://packagecloud.io/sensu/stable/ubuntu bionic main
- change mode from '' to '0644'
* execute[apt-key-add-sensu_stable] action run
- execute wget --auth-no-challenge -qO - https://packagecloud.io/sensu/stable/gpgkey | apt-key add -
* execute[apt-get-update-sensu_stable] action run
- execute apt-get update -o Dir::Etc::sourcelist="sources.list.d/sensu_stable.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
* apt_package[sensu-go-backend] action upgrade
- upgrade package sensu-go-backend from uninstalled to 5.14.1-6721
* file[/etc/sensu/backend.yml] action create
- create new file /etc/sensu/backend.yml
- update content in file /etc/sensu/backend.yml from none to 65e23e
--- /etc/sensu/backend.yml 2019-10-26 02:03:20.679027352 +0000
+++ /etc/sensu/.chef-backend20191026-62-qyu8px.yml 2019-10-26 02:03:20.679027352 +0000
@@ -1 +1,3 @@
+---
+state-dir: "/var/lib/sensu/sensu-backend"
* service[sensu-backend] action enable
- enable service service[sensu-backend]
* service[sensu-backend] action start
- start service service[sensu-backend]
* sensu_agent[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-agent] action upgrade
- upgrade package sensu-go-agent from uninstalled to 5.14.1-6721
* file[/etc/sensu/agent.yml] action create
- create new file /etc/sensu/agent.yml
- update content in file /etc/sensu/agent.yml from none to 1aa655
--- /etc/sensu/agent.yml 2019-10-26 02:03:26.717712274 +0000
+++ /etc/sensu/.chef-agent20191026-62-egnslp.yml 2019-10-26 02:03:26.717712274 +0000
@@ -1 +1,6 @@
+---
+name: dokken
+namespace: default
+backend-url:
+- ws://127.0.0.1:8081
* service[sensu-agent] action enable
- enable service service[sensu-agent]
* service[sensu-agent] action start
- start service service[sensu-agent]
* sensu_ctl[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-cli] action install
- install version 5.14.1-6721 of package sensu-go-cli
* sensu_ctl[default] action configure
- Reconfiguring sensuctl
* execute[configure sensuctl] action run
- execute ["/usr/bin/sensuctl", "configure", "--non-interactive", "--username", "admin", "--password", "P@ssw0rd!", "--url", "http://127.0.0.1:8080"]
* sensu_namespace[test-org] action create
* directory[/etc/sensu/namespaces] action create
- create new directory /etc/sensu/namespaces
* file[/etc/sensu/namespaces/test-org.json] action create
- create new file /etc/sensu/namespaces/test-org.json
- update content in file /etc/sensu/namespaces/test-org.json from none to 70ab98
--- /etc/sensu/namespaces/test-org.json 2019-10-26 02:03:32.648773059 +0000
+++ /etc/sensu/namespaces/.chef-test-org20191026-62-1kmwgi1.json 2019-10-26 02:03:32.648773059 +0000
@@ -1 +1,2 @@
+{"type":"namespace","spec":{"name":"test-org"}}
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action run
- execute sensuctl create -f /etc/sensu/namespaces/test-org.json
* sensu_check[cron] action create
* directory[/etc/sensu/checks] action create
- create new directory /etc/sensu/checks
* file[/etc/sensu/checks/cron.json] action create
- create new file /etc/sensu/checks/cron.json
- update content in file /etc/sensu/checks/cron.json from none to 3271c6
--- /etc/sensu/checks/cron.json 2019-10-26 02:03:32.676769229 +0000
+++ /etc/sensu/checks/.chef-cron20191026-62-wjmod8.json 2019-10-26 02:03:32.676769229 +0000
@@ -1 +1,2 @@
+{"type":"check","spec":{"command":"/bin/true","cron":"@hourly","metadata":{"name":"cron","namespace":"default","labels":{"environment":"production","region":"us-west-2"},"annotations":{"runbook":"https://www.xkcd.com/378/"}},"handlers":["pagerduty","email"],"high_flap_threshold":60,"low_flap_threshold":20,"stdin":false,"subdue":{"days":{"all":[{"begin":"12:00 AM","end":"11:59 PM"},{"begin":"11:00 PM","end":"1:00 AM"}]}},"subscriptions":["dad_jokes","production"],"ttl":100}}
* execute[sensuctl create -f /etc/sensu/checks/cron.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/checks/cron.json] action run
- execute sensuctl create -f /etc/sensu/checks/cron.json
* sensu_asset[sensu-plugins-http] action create
* directory[/etc/sensu/assets] action create
- create new directory /etc/sensu/assets
* file[/etc/sensu/assets/sensu-plugins-http.json] action create
- create new file /etc/sensu/assets/sensu-plugins-http.json
- update content in file /etc/sensu/assets/sensu-plugins-http.json from none to 869540
--- /etc/sensu/assets/sensu-plugins-http.json 2019-10-26 02:03:32.700765947 +0000
+++ /etc/sensu/assets/.chef-sensu-plugins-http20191026-62-dog0gy.json2019-10-26 02:03:32.700765947 +0000
@@ -1 +1,2 @@
+{"type":"asset","spec":{"metadata":{"name":"sensu-plugins-http","namespace":"default"},"sha512":"b57cacd2b479f41b5d002c037ac3005e7a655d1dfae93c457f0c19dde21fc992771b5d290a2cce9255578d9bd2fc88075646e3e0e02e3c01d8e1e274ae0b7376","url":"https://github.com/sensu-plugins/sensu-plugins-http/archive/2.9.0.tar.gz"}}
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json] action run
- execute sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json
* sensu_asset[sensu-plugins-docker] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-docker.json] action create
- create new file /etc/sensu/assets/sensu-plugins-docker.json
- update content in file /etc/sensu/assets/sensu-plugins-docker.json from none to 8da084
--- /etc/sensu/assets/sensu-plugins-docker.json 2019-10-26 02:03:32.728762117 +0000
+++ /etc/sensu/assets/.chef-sensu-plugins-docker20191026-62-1hl2s9o.json 2019-10-26 02:03:32.728762117 +0000
@@ -1 +1,2 @@
+{"type":"asset","spec":{"metadata":{"name":"sensu-plugins-docker","namespace":"default"},"sha512":"96f71be5824ae50db8992ffdd1a94076170457cd9ca4f8563d739ffb07d65aca06c1d2ff5590b10f73089b300a74a3c5c255dcd9a4649487aa81a29e4f81c85c","url":"https://github.com/sensu-plugins/sensu-plugins-docker/archive/3.0.0.tar.gz"}}
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json] action run
- execute sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json
* sensu_asset[sensu-plugins-postgres] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-postgres.json] action create
- create new file /etc/sensu/assets/sensu-plugins-postgres.json
- update content in file /etc/sensu/assets/sensu-plugins-postgres.json from none to 65f3eb
--- /etc/sensu/assets/sensu-plugins-postgres.json 2019-10-26 02:03:32.760757740 +0000
+++ /etc/sensu/assets/.chef-sensu-plugins-postgres20191026-62-1cm08hm.json 2019-10-26 02:03:32.760757740 +0000
@@ -1 +1,2 @@
+{"type":"asset","spec":{"metadata":{"name":"sensu-plugins-postgres","namespace":"default"},"sha512":"b4369e69f3e3247b6f48596733da2f1a3c66fceebb60e6b00c70f404324876696fc8d2381206c47bd9d09227b2d6d3802f359e2ae349d71930bd0d45c0b3d554","url":"https://github.com/sensu-plugins/sensu-plugins-postgres/archive/1.4.6.tar.gz"}}
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json] action run
- execute sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json
* sensu_asset[sensu-slack-handler] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-slack-handler.json] action create
- create new file /etc/sensu/assets/sensu-slack-handler.json
- update content in file /etc/sensu/assets/sensu-slack-handler.json from none to 3fb8f1
--- /etc/sensu/assets/sensu-slack-handler.json 2019-10-26 02:03:32.788753910 +0000
+++ /etc/sensu/assets/.chef-sensu-slack-handler20191026-62-19o0ldi.json 2019-10-26 02:03:32.788753910 +0000
@@ -1 +1,2 @@
+{"type":"asset","spec":{"metadata":{"name":"sensu-slack-handler","namespace":"default"},"sha512":"68720865127fbc7c2fe16ca4d7bbf2a187a2df703f4b4acae1c93e8a66556e9079e1270521999b5871473e6c851f51b34097c54fdb8d18eedb7064df9019adc8","url":"https://github.com/sensu/sensu-slack-handler/releases/download/1.0.3/sensu-slack-handler_1.0.3_linux_amd64.tar.gz"}}
* execute[sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json] action run
- execute sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json
* sensu_handler[slack] action create
* directory[/etc/sensu/handlers] action create
- create new directory /etc/sensu/handlers
* file[/etc/sensu/handlers/slack.json] action create
- create new file /etc/sensu/handlers/slack.json
- update content in file /etc/sensu/handlers/slack.json from none to dc3dab
--- /etc/sensu/handlers/slack.json 2019-10-26 02:03:32.824748985 +0000
+++ /etc/sensu/handlers/.chef-slack20191026-62-4rvkb3.json 2019-10-26 02:03:32.824748985 +0000
@@ -1 +1,2 @@
+{"type":"handler","spec":{"command":"sensu-slack-handler --channel monitoring","env_vars":["SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"],"metadata":{"name":"slack","namespace":"default"},"runtime_assets":["sensu-slack-handler"],"type":"pipe"}}
* execute[sensuctl create -f /etc/sensu/handlers/slack.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/handlers/slack.json] action run
- execute sensuctl create -f /etc/sensu/handlers/slack.json
* sensu_handler[tcp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/tcp_handler.json] action create
- create new file /etc/sensu/handlers/tcp_handler.json
- update content in file /etc/sensu/handlers/tcp_handler.json from none to f25cfd
--- /etc/sensu/handlers/tcp_handler.json 2019-10-26 02:03:32.864743514 +0000
+++ /etc/sensu/handlers/.chef-tcp_handler20191026-62-b2u65y.json 2019-10-26 02:03:32.864743514 +0000
@@ -1 +1,2 @@
+{"type":"handler","spec":{"metadata":{"name":"tcp_handler","namespace":"default"},"socket":{"host":"127.0.0.1","port":4444},"timeout":30,"type":"tcp"}}
* execute[sensuctl create -f /etc/sensu/handlers/tcp_handler.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/handlers/tcp_handler.json] action run
- execute sensuctl create -f /etc/sensu/handlers/tcp_handler.json
* sensu_handler[udp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/udp_handler.json] action create
- create new file /etc/sensu/handlers/udp_handler.json
- update content in file /etc/sensu/handlers/udp_handler.json from none to 0f2da0
--- /etc/sensu/handlers/udp_handler.json 2019-10-26 02:03:32.892739684 +0000
+++ /etc/sensu/handlers/.chef-udp_handler20191026-62-1lj5ysy.json 2019-10-26 02:03:32.892739684 +0000
@@ -1 +1,2 @@
+{"type":"handler","spec":{"metadata":{"name":"udp_handler","namespace":"default"},"socket":{"host":"127.0.0.1","port":4444},"timeout":30,"type":"udp"}}
* execute[sensuctl create -f /etc/sensu/handlers/udp_handler.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/handlers/udp_handler.json] action run
- execute sensuctl create -f /etc/sensu/handlers/udp_handler.json
* sensu_handler[notify_the_world] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/notify_the_world.json] action create
- create new file /etc/sensu/handlers/notify_the_world.json
- update content in file /etc/sensu/handlers/notify_the_world.json from none to 350bba
--- /etc/sensu/handlers/notify_the_world.json 2019-10-26 02:03:32.924735307 +0000
+++ /etc/sensu/handlers/.chef-notify_the_world20191026-62-1wo7px1.json 2019-10-26 02:03:32.924735307 +0000
@@ -1 +1,2 @@
+{"type":"handler","spec":{"metadata":{"name":"notify_the_world","namespace":"default"},"handlers":["slack","tcp_handler","udp_handler"],"type":"set"}}
* execute[sensuctl create -f /etc/sensu/handlers/notify_the_world.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/handlers/notify_the_world.json] action run
- execute sensuctl create -f /etc/sensu/handlers/notify_the_world.json
* sensu_filter[production_filter] action create
* directory[/etc/sensu/filters] action create
- create new directory /etc/sensu/filters
* file[/etc/sensu/filters/production_filter.json] action create
- create new file /etc/sensu/filters/production_filter.json
- update content in file /etc/sensu/filters/production_filter.json from none to 91009b
--- /etc/sensu/filters/production_filter.json 2019-10-26 02:03:32.952731477 +0000
+++ /etc/sensu/filters/.chef-production_filter20191026-62-8bqlhu.json2019-10-26 02:03:32.952731477 +0000
@@ -1 +1,2 @@
+{"type":"event_filter","spec":{"action":"allow","metadata":{"name":"production_filter","namespace":"default"},"expressions":["event.Entity.Environment == 'production'"]}}
* execute[sensuctl create -f /etc/sensu/filters/production_filter.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/filters/production_filter.json] action run
- execute sensuctl create -f /etc/sensu/filters/production_filter.json
* sensu_filter[development_filter] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/development_filter.json] action create
- create new file /etc/sensu/filters/development_filter.json
- update content in file /etc/sensu/filters/development_filter.json from none to ff4313
--- /etc/sensu/filters/development_filter.json 2019-10-26 02:03:32.988726553 +0000
+++ /etc/sensu/filters/.chef-development_filter20191026-62-40uo2d.json 2019-10-26 02:03:32.988726553 +0000
@@ -1 +1,2 @@
+{"type":"event_filter","spec":{"action":"deny","metadata":{"name":"development_filter","namespace":"default"},"expressions":["event.Entity.Environment == 'production'"]}}
* execute[sensuctl create -f /etc/sensu/filters/development_filter.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/filters/development_filter.json] action run
- execute sensuctl create -f /etc/sensu/filters/development_filter.json
* sensu_filter[state_change_only] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/state_change_only.json] action create
- create new file /etc/sensu/filters/state_change_only.json
- update content in file /etc/sensu/filters/state_change_only.json from none to 6491ff
--- /etc/sensu/filters/state_change_only.json 2019-10-26 02:03:33.016722840 +0000
+++ /etc/sensu/filters/.chef-state_change_only20191026-62-13bj8rb.json 2019-10-26 02:03:33.016722840 +0000
@@ -1 +1,2 @@
+{"type":"event_filter","spec":{"action":"allow","metadata":{"name":"state_change_only","namespace":"default"},"expressions":["event.Check.Occurrences == 1"]}}
* execute[sensuctl create -f /etc/sensu/filters/state_change_only.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/filters/state_change_only.json] action run
- execute sensuctl create -f /etc/sensu/filters/state_change_only.json
* sensu_filter[filter_interval_60_hourly] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/filter_interval_60_hourly.json] action create
- create new file /etc/sensu/filters/filter_interval_60_hourly.json
- update content in file /etc/sensu/filters/filter_interval_60_hourly.json from none to a4680c
--- /etc/sensu/filters/filter_interval_60_hourly.json 2019-10-26 02:03:33.044719190 +0000
+++ /etc/sensu/filters/.chef-filter_interval_60_hourly20191026-62-mk2zr2.json 2019-10-26 02:03:33.044719190 +0000
@@ -1 +1,2 @@
+{"type":"event_filter","spec":{"action":"allow","metadata":{"name":"filter_interval_60_hourly","namespace":"default"},"expressions":["event.Check.Interval == 60","event.Check.Occurrences == 1 || event.Check.Occurrences % 60 == 0"]}}
* execute[sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json] action run
- execute sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json
* sensu_filter[nine_to_fiver] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/nine_to_fiver.json] action create
- create new file /etc/sensu/filters/nine_to_fiver.json
- update content in file /etc/sensu/filters/nine_to_fiver.json from none to 8d9fed
--- /etc/sensu/filters/nine_to_fiver.json 2019-10-26 02:03:33.076715018 +0000
+++ /etc/sensu/filters/.chef-nine_to_fiver20191026-62-13ndgih.json 2019-10-26 02:03:33.076715018 +0000
@@ -1 +1,2 @@
+{"type":"event_filter","spec":{"action":"allow","metadata":{"name":"nine_to_fiver","namespace":"default"},"expressions":["weekday(event.Timestamp) >= 1 && weekday(event.Timestamp) <= 5","hour(event.Timestamp) >= 9 && hour(event.Timestamp) <= 17"]}}
* execute[sensuctl create -f /etc/sensu/filters/nine_to_fiver.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/filters/nine_to_fiver.json] action run
- execute sensuctl create -f /etc/sensu/filters/nine_to_fiver.json
* sensu_mutator[example-mutator] action create
* directory[/etc/sensu/mutators] action create
- create new directory /etc/sensu/mutators
* file[/etc/sensu/mutators/example-mutator.json] action create
- create new file /etc/sensu/mutators/example-mutator.json
- update content in file /etc/sensu/mutators/example-mutator.json from none to 83fdf6
--- /etc/sensu/mutators/example-mutator.json 2019-10-26 02:03:33.104711367 +0000
+++ /etc/sensu/mutators/.chef-example-mutator20191026-62-fpodlw.json2019-10-26 02:03:33.104711367 +0000
@@ -1 +1,2 @@
+{"type":"mutator","spec":{"command":"example_mutator.rb","metadata":{"name":"example-mutator","namespace":"default"},"timeout":60}}
* execute[sensuctl create -f /etc/sensu/mutators/example-mutator.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/mutators/example-mutator.json] action run
- execute sensuctl create -f /etc/sensu/mutators/example-mutator.json
* sensu_entity[example-entity] action create
* directory[/etc/sensu/entitys] action create
- create new directory /etc/sensu/entitys
* file[/etc/sensu/entitys/example-entity.json] action create
- create new file /etc/sensu/entitys/example-entity.json
- update content in file /etc/sensu/entitys/example-entity.json from none to 17e203
--- /etc/sensu/entitys/example-entity.json 2019-10-26 02:03:33.140706673 +0000
+++ /etc/sensu/entitys/.chef-example-entity20191026-62-1ps3eaw.json 2019-10-26 02:03:33.140706673 +0000
@@ -1 +1,2 @@
+{"type":"entity","spec":{"subscriptions":["example-entity"],"metadata":{"name":"example-entity","namespace":"default","labels":{"environment":"production","region":"us-west-2"},"annotations":{"runbook":"https://www.xkcd.com/378/"}},"entity_class":"proxy"}}
* execute[sensuctl create -f /etc/sensu/entitys/example-entity.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/entitys/example-entity.json] action run
- execute sensuctl create -f /etc/sensu/entitys/example-entity.json
* sensu_hook[restart_cron_service] action create
* directory[/etc/sensu/hooks] action create
- create new directory /etc/sensu/hooks
* file[/etc/sensu/hooks/restart_cron_service.json] action create
- create new file /etc/sensu/hooks/restart_cron_service.json
- update content in file /etc/sensu/hooks/restart_cron_service.json from none to 07baaf
--- /etc/sensu/hooks/restart_cron_service.json 2019-10-26 02:03:33.172702501 +0000
+++ /etc/sensu/hooks/.chef-restart_cron_service20191026-62-fux513.json 2019-10-26 02:03:33.172702501 +0000
@@ -1 +1,2 @@
+{"type":"hook","spec":{"command":"sudo service cron restart","timeout":60,"metadata":{"name":"restart_cron_service","namespace":"default"}}}
* execute[sensuctl create -f /etc/sensu/hooks/restart_cron_service.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/hooks/restart_cron_service.json] action run
- execute sensuctl create -f /etc/sensu/hooks/restart_cron_service.json
Running handlers:
Running handlers complete
Chef Client finished, 80/130 resources updated in 22 seconds
Finished converging <default-ubuntu-1804> (0m25.02s).
-----> Kitchen is finished. (0m28.23s)
# login and verify where config is:
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen login default-ubuntu-1804
root@dokken:/# sensuctl config view
=== Active Configuration
API URL: http://127.0.0.1:8080
Namespace: default
Format: tabular
Username: admin
root@dokken:/# ls -l /root/.config/sensu/sensuctl
total 8
-rw-r--r-- 1 root root 764 Oct 26 02:03 cluster
-rw-r--r-- 1 root root 51 Oct 26 02:03 profile
root@dokken:/# cat /root/.config/sensu/sensuctl/*
{
"api-url": "http://127.0.0.1:8080",
"trusted-ca-file": "",
"insecure-skip-tls-verify": false,
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzIwNTYzMTIsImp0aSI6ImRlNTcxMDNlOTE5MTMyNzgxN2I0OWU4YzE1ZWQwNzMwIiwic3ViIjoiYWRtaW4iLCJncm91cHMiOlsiY2x1c3Rlci1hZG1pbnMiLCJzeXN0ZW06dXNlcnMiXSwicHJvdmlkZXIiOnsicHJvdmlkZXJfaWQiOiJiYXNpYyIsInByb3ZpZGVyX3R5cGUiOiIiLCJ1c2VyX2lkIjoiYWRtaW4ifX0.g2M3TpCcLL7oMIBCoil1pt-IR5nv5CRA0F8pXuRBgYg",
"expires_at": 1572056312,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkMjlkNjQ3ZTdkMWE4MDA0ZTQyZWU1ODNiYmZkNzMzMCIsInN1YiI6ImFkbWluIiwiZ3JvdXBzIjpudWxsLCJwcm92aWRlciI6eyJwcm92aWRlcl9pZCI6IiIsInByb3ZpZGVyX3R5cGUiOiIiLCJ1c2VyX2lkIjoiIn19.owhMr4g04MrYFFptDEh6393yK5x9ToQXpMjegglwrvA"
}{
"format": "tabular",
"namespace": "default"
}
# manually create a new user to connect as
root@dokken:/# sensuctl user create admin2 --password='password' --groups=cluster-admins
Created
root@dokken:/# sensuctl user list --format yaml
type: User
api_version: core/v2
metadata:
name: admin
spec:
disabled: false
groups:
- cluster-admins
username: admin
---
type: User
api_version: core/v2
metadata:
name: admin2
spec:
disabled: false
groups:
- cluster-admins
username: admin2
---
type: User
api_version: core/v2
metadata:
name: agent
spec:
disabled: false
groups:
- system:agents
username: agent
# showing the modified files that we will use to connect as a second pass
$ git diff
diff --git a/test/cookbooks/sensu_test/recipes/default.rb b/test/cookbooks/sensu_test/recipes/default.rb
index d62c012..3b18bc0 100644
--- a/test/cookbooks/sensu_test/recipes/default.rb
+++ b/test/cookbooks/sensu_test/recipes/default.rb
@@ -5,6 +5,8 @@ sensu_agent 'default'
sensu_ctl 'default' do
action [:install, :configure]
debug true
+ username 'admin2'
+ password 'password'
end
sensu_namespace 'test-org' do
# re-running
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen converge default-ubuntu-1804
-----> Starting Kitchen (v1.21.2)
-----> Converging <default-ubuntu-1804>...
Creating kitchen sandbox in /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 7.0.4...
Removing non-cookbook files before transfer
Preparing data_bags
Preparing validation.pem
Preparing client.rb
Starting Chef Client, version 14.5.0
Creating a new client identity for default-ubuntu-1804 using the validator key.
resolving cookbooks for run list: ["sensu_test::default"]
Synchronizing Cookbooks:
- sensu-go (0.1.0)
- packagecloud (1.0.0)
- sensu_test (0.0.1)
- seven_zip (3.1.2)
- windows (6.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 21 resources
Recipe: sensu_test::default
* sensu_backend[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-backend] action upgrade (up to date)
* file[/etc/sensu/backend.yml] action create (up to date)
* service[sensu-backend] action enable (up to date)
* service[sensu-backend] action start (up to date)
(up to date)
* sensu_agent[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-agent] action upgrade (up to date)
* file[/etc/sensu/agent.yml] action create (up to date)
* service[sensu-agent] action enable (up to date)
* service[sensu-agent] action start (up to date)
(up to date)
* sensu_ctl[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-cli] action install (up to date)
(up to date)
* sensu_ctl[default] action configure (up to date)
* sensu_namespace[test-org] action create
* directory[/etc/sensu/namespaces] action create (up to date)
* file[/etc/sensu/namespaces/test-org.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_check[cron] action create
* directory[/etc/sensu/checks] action create (up to date)
* file[/etc/sensu/checks/cron.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/checks/cron.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-http] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-http.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-docker] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-docker.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-postgres] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-postgres.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-slack-handler] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-slack-handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[slack] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/slack.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/slack.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[tcp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/tcp_handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/tcp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[udp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/udp_handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/udp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[notify_the_world] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/notify_the_world.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/notify_the_world.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[production_filter] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/production_filter.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/production_filter.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[development_filter] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/development_filter.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/development_filter.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[state_change_only] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/state_change_only.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/state_change_only.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[filter_interval_60_hourly] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/filter_interval_60_hourly.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[nine_to_fiver] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/nine_to_fiver.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/nine_to_fiver.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_mutator[example-mutator] action create
* directory[/etc/sensu/mutators] action create (up to date)
* file[/etc/sensu/mutators/example-mutator.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/mutators/example-mutator.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_entity[example-entity] action create
* directory[/etc/sensu/entitys] action create (up to date)
* file[/etc/sensu/entitys/example-entity.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/entitys/example-entity.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_hook[restart_cron_service] action create
* directory[/etc/sensu/hooks] action create (up to date)
* file[/etc/sensu/hooks/restart_cron_service.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/hooks/restart_cron_service.json] action nothing (skipped due to action :nothing)
(up to date)
Running handlers:
Running handlers complete
Chef Client finished, 0/109 resources updated in 10 seconds
Finished converging <default-ubuntu-1804> (0m11.55s).
-----> Kitchen is finished. (0m12.73s)
# we see no resources were changed but for shiggles lets verify
root@dokken:/# sensuctl config view
=== Active Configuration
API URL: http://127.0.0.1:8080
Namespace: default
Format: tabular
Username: admin
# attempt to manually configure
root@dokken:/# sensuctl config view
=== Active Configuration
API URL: http://127.0.0.1:8080
Namespace: default
Format: tabular
Username: admin
root@dokken:/# sensuctl configure
? Sensu Backend URL: http://127.0.0.1:8080
? Username: admin2
? Password: ********
? Namespace: default
? Preferred output format: tabular
# verify manually it works
root@dokken:/# sensuctl config view
=== Active Configuration
API URL: http://127.0.0.1:8080
Namespace: default
Format: tabular
Username: admin2
# it still does not pick up the changes
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen converge default-ubuntu-1804
-----> Starting Kitchen (v1.21.2)
-----> Converging <default-ubuntu-1804>...
Creating kitchen sandbox in /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 7.0.4...
Removing non-cookbook files before transfer
Preparing data_bags
Preparing validation.pem
Preparing client.rb
Starting Chef Client, version 14.5.0
Creating a new client identity for default-ubuntu-1804 using the validator key.
resolving cookbooks for run list: ["sensu_test::default"]
Synchronizing Cookbooks:
- sensu_test (0.0.1)
- sensu-go (0.1.0)
- packagecloud (1.0.0)
- seven_zip (3.1.2)
- windows (6.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 21 resources
Recipe: sensu_test::default
* sensu_backend[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-backend] action upgrade (up to date)
* file[/etc/sensu/backend.yml] action create (up to date)
* service[sensu-backend] action enable (up to date)
* service[sensu-backend] action start (up to date)
(up to date)
* sensu_agent[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-agent] action upgrade (up to date)
* file[/etc/sensu/agent.yml] action create (up to date)
* service[sensu-agent] action enable (up to date)
* service[sensu-agent] action start (up to date)
(up to date)
* sensu_ctl[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-cli] action install (up to date)
(up to date)
* sensu_ctl[default] action configure (up to date)
* sensu_namespace[test-org] action create
* directory[/etc/sensu/namespaces] action create (up to date)
* file[/etc/sensu/namespaces/test-org.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_check[cron] action create
* directory[/etc/sensu/checks] action create (up to date)
* file[/etc/sensu/checks/cron.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/checks/cron.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-http] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-http.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-docker] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-docker.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-plugins-postgres] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-plugins-postgres.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_asset[sensu-slack-handler] action create
* directory[/etc/sensu/assets] action create (up to date)
* file[/etc/sensu/assets/sensu-slack-handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[slack] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/slack.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/slack.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[tcp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/tcp_handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/tcp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[udp_handler] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/udp_handler.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/udp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_handler[notify_the_world] action create
* directory[/etc/sensu/handlers] action create (up to date)
* file[/etc/sensu/handlers/notify_the_world.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/handlers/notify_the_world.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[production_filter] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/production_filter.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/production_filter.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[development_filter] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/development_filter.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/development_filter.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[state_change_only] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/state_change_only.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/state_change_only.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[filter_interval_60_hourly] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/filter_interval_60_hourly.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_filter[nine_to_fiver] action create
* directory[/etc/sensu/filters] action create (up to date)
* file[/etc/sensu/filters/nine_to_fiver.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/filters/nine_to_fiver.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_mutator[example-mutator] action create
* directory[/etc/sensu/mutators] action create (up to date)
* file[/etc/sensu/mutators/example-mutator.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/mutators/example-mutator.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_entity[example-entity] action create
* directory[/etc/sensu/entitys] action create (up to date)
* file[/etc/sensu/entitys/example-entity.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/entitys/example-entity.json] action nothing (skipped due to action :nothing)
(up to date)
* sensu_hook[restart_cron_service] action create
* directory[/etc/sensu/hooks] action create (up to date)
* file[/etc/sensu/hooks/restart_cron_service.json] action create (up to date)
* execute[sensuctl create -f /etc/sensu/hooks/restart_cron_service.json] action nothing (skipped due to action :nothing)
(up to date)
Running handlers:
Running handlers complete
Chef Client finished, 0/109 resources updated in 10 seconds
Finished converging <default-ubuntu-1804> (0m11.71s).
-----> Kitchen is finished. (0m12.89s)
@scalp42 I suspect your right about if shell_out('sensuctl user list').error?
I can't say I recall why we did that my guess was that this was something that was done to detect if it was not configured at all. When I changed it to if !shell_out('sensuctl user list').error?
it did what I expected. @webframp do you recall why this was done?
- sensu_namespace[test-org] action create
- directory[/etc/sensu/namespaces] action create (up to date)
- file[/etc/sensu/namespaces/test-org.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_check[cron] action create
- directory[/etc/sensu/checks] action create (up to date)
- file[/etc/sensu/checks/cron.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/checks/cron.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_asset[sensu-plugins-http] action create
- directory[/etc/sensu/assets] action create (up to date)
- file[/etc/sensu/assets/sensu-plugins-http.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-http.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_asset[sensu-plugins-docker] action create
- directory[/etc/sensu/assets] action create (up to date)
- file[/etc/sensu/assets/sensu-plugins-docker.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-docker.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_asset[sensu-plugins-postgres] action create
- directory[/etc/sensu/assets] action create (up to date)
- file[/etc/sensu/assets/sensu-plugins-postgres.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/assets/sensu-plugins-postgres.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_asset[sensu-slack-handler] action create
- directory[/etc/sensu/assets] action create (up to date)
- file[/etc/sensu/assets/sensu-slack-handler.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/assets/sensu-slack-handler.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_handler[slack] action create
- directory[/etc/sensu/handlers] action create (up to date)
- file[/etc/sensu/handlers/slack.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/handlers/slack.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_handler[tcp_handler] action create
- directory[/etc/sensu/handlers] action create (up to date)
- file[/etc/sensu/handlers/tcp_handler.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/handlers/tcp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_handler[udp_handler] action create
- directory[/etc/sensu/handlers] action create (up to date)
- file[/etc/sensu/handlers/udp_handler.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/handlers/udp_handler.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_handler[notify_the_world] action create
- directory[/etc/sensu/handlers] action create (up to date)
- file[/etc/sensu/handlers/notify_the_world.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/handlers/notify_the_world.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_filter[production_filter] action create
- directory[/etc/sensu/filters] action create (up to date)
- file[/etc/sensu/filters/production_filter.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/filters/production_filter.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_filter[development_filter] action create
- directory[/etc/sensu/filters] action create (up to date)
- file[/etc/sensu/filters/development_filter.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/filters/development_filter.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_filter[state_change_only] action create
- directory[/etc/sensu/filters] action create (up to date)
- file[/etc/sensu/filters/state_change_only.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/filters/state_change_only.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_filter[filter_interval_60_hourly] action create
- directory[/etc/sensu/filters] action create (up to date)
- file[/etc/sensu/filters/filter_interval_60_hourly.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/filters/filter_interval_60_hourly.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_filter[nine_to_fiver] action create
- directory[/etc/sensu/filters] action create (up to date)
- file[/etc/sensu/filters/nine_to_fiver.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/filters/nine_to_fiver.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_mutator[example-mutator] action create
- directory[/etc/sensu/mutators] action create (up to date)
- file[/etc/sensu/mutators/example-mutator.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/mutators/example-mutator.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_entity[example-entity] action create
- directory[/etc/sensu/entitys] action create (up to date)
- file[/etc/sensu/entitys/example-entity.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/entitys/example-entity.json] action nothing (skipped due to action :nothing)
(up to date)
- sensu_hook[restart_cron_service] action create
- directory[/etc/sensu/hooks] action create (up to date)
- file[/etc/sensu/hooks/restart_cron_service.json] action create (up to date)
- execute[sensuctl create -f /etc/sensu/hooks/restart_cron_service.json] action nothing (skipped due to action :nothing)
(up to date)
Running handlers:
Running handlers complete
Chef Client finished, 2/110 resources updated in 10 seconds
Finished converging (0m18.61s).
-----> Kitchen is finished. (0m19.75s)
</details>
I attempted to try again with default credentials and got an error with the change:
$ git diff
diff --git a/resources/ctl.rb b/resources/ctl.rb
index f8103e9..1ef98f8 100644
--- a/resources/ctl.rb
+++ b/resources/ctl.rb
@@ -103,7 +103,7 @@ action :install do
end
action :configure do
- if shell_out('sensuctl user list').error?
+ if !shell_out('sensuctl user list').error?
converge_by 'Reconfiguring sensuctl' do
execute 'configure sensuctl' do
command sensuctl_configure_cmd
diff --git a/test/cookbooks/sensu_test/recipes/default.rb b/test/cookbooks/sensu_test/recipes/default.rb
index d62c012..a5ed3fb 100644
--- a/test/cookbooks/sensu_test/recipes/default.rb
+++ b/test/cookbooks/sensu_test/recipes/default.rb
@@ -5,6 +5,8 @@ sensu_agent 'default'
sensu_ctl 'default' do
action [:install, :configure]
debug true
+ # username 'admin2'
+ # password 'password'
end
sensu_namespace 'test-org' do
$ KITCHEN_LOCAL_YAML=.kitchen.dokken.yml bundle exec kitchen converge default-ubuntu-1804
-----> Starting Kitchen (v1.21.2)
-----> Creating <default-ubuntu-1804>...
Creating kitchen sandbox at /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Creating verifier sandbox at /home/babrams/.dokken/verifier_sandbox/c488ee9495-default-ubuntu-1804
Building work image..
Creating container c488ee9495-default-ubuntu-1804
Finished creating <default-ubuntu-1804> (0m2.10s).
-----> Converging <default-ubuntu-1804>...
Creating kitchen sandbox in /home/babrams/.dokken/kitchen_sandbox/c488ee9495-default-ubuntu-1804
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 7.0.4...
Removing non-cookbook files before transfer
Preparing data_bags
Preparing validation.pem
Preparing client.rb
Starting Chef Client, version 14.5.0
Creating a new client identity for default-ubuntu-1804 using the validator key.
resolving cookbooks for run list: ["sensu_test::default"]
Synchronizing Cookbooks:
- sensu-go (0.1.0)
- packagecloud (1.0.0)
- seven_zip (3.1.2)
- sensu_test (0.0.1)
- windows (6.0.1)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 21 resources
Recipe: sensu_test::default
* sensu_backend[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create
- create new file /etc/apt/sources.list.d/sensu_stable.list
- update content in file /etc/apt/sources.list.d/sensu_stable.list from none to 0c5ca9
--- /etc/apt/sources.list.d/sensu_stable.list 2019-10-26 02:51:42.081593480 +0000
+++ /etc/apt/sources.list.d/.chef-sensu_stable20191026-77-18f6pba.list 2019-10-26 02:51:42.081593480 +0000
@@ -1 +1,3 @@
+deb https://packagecloud.io/sensu/stable/ubuntu bionic main
+deb-src https://packagecloud.io/sensu/stable/ubuntu bionic main
- change mode from '' to '0644'
* execute[apt-key-add-sensu_stable] action run
- execute wget --auth-no-challenge -qO - https://packagecloud.io/sensu/stable/gpgkey | apt-key add -
* execute[apt-get-update-sensu_stable] action run
- execute apt-get update -o Dir::Etc::sourcelist="sources.list.d/sensu_stable.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
* apt_package[sensu-go-backend] action upgrade
- upgrade package sensu-go-backend from uninstalled to 5.14.1-6721
* file[/etc/sensu/backend.yml] action create
- create new file /etc/sensu/backend.yml
- update content in file /etc/sensu/backend.yml from none to 65e23e
--- /etc/sensu/backend.yml 2019-10-26 02:51:47.327403848 +0000
+++ /etc/sensu/.chef-backend20191026-77-1yrxtyy.yml 2019-10-26 02:51:47.327403848 +0000
@@ -1 +1,3 @@
+---
+state-dir: "/var/lib/sensu/sensu-backend"
* service[sensu-backend] action enable
- enable service service[sensu-backend]
* service[sensu-backend] action start
- start service service[sensu-backend]
* sensu_agent[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-agent] action upgrade
- upgrade package sensu-go-agent from uninstalled to 5.14.1-6721
* file[/etc/sensu/agent.yml] action create
- create new file /etc/sensu/agent.yml
- update content in file /etc/sensu/agent.yml from none to 1aa655
--- /etc/sensu/agent.yml 2019-10-26 02:51:53.561525066 +0000
+++ /etc/sensu/.chef-agent20191026-77-p9v8fg.yml 2019-10-26 02:51:53.561525066 +0000
@@ -1 +1,6 @@
+---
+name: dokken
+namespace: default
+backend-url:
+- ws://127.0.0.1:8081
* service[sensu-agent] action enable
- enable service service[sensu-agent]
* service[sensu-agent] action start
- start service service[sensu-agent]
* sensu_ctl[default] action install
* packagecloud_repo[sensu/stable] action add
* apt_package[wget] action install (up to date)
* apt_package[apt-transport-https] action install (up to date)
* apt_package[lsb-release] action install (up to date)
* ohai[reload-lsb-sensu_stable] action nothing (skipped due to action :nothing)
* template[/etc/apt/sources.list.d/sensu_stable.list] action create (up to date)
* execute[apt-key-add-sensu_stable] action nothing (skipped due to action :nothing)
* execute[apt-get-update-sensu_stable] action nothing (skipped due to action :nothing)
(up to date)
* apt_package[sensu-go-cli] action install
- install version 5.14.1-6721 of package sensu-go-cli
* sensu_ctl[default] action configure (up to date)
* sensu_namespace[test-org] action create
* directory[/etc/sensu/namespaces] action create
- create new directory /etc/sensu/namespaces
* file[/etc/sensu/namespaces/test-org.json] action create
- create new file /etc/sensu/namespaces/test-org.json
- update content in file /etc/sensu/namespaces/test-org.json from none to 70ab98
--- /etc/sensu/namespaces/test-org.json 2019-10-26 02:51:59.540232191 +0000
+++ /etc/sensu/namespaces/.chef-test-org20191026-77-114ma3a.json 2019-10-26 02:51:59.540232191 +0000
@@ -1 +1,2 @@
+{"type":"namespace","spec":{"name":"test-org"}}
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action nothing (skipped due to action :nothing)
* execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] action run
================================================================================
Error executing action `run` on resource 'execute[sensuctl create -f /etc/sensu/namespaces/test-org.json]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
STDOUT:
STDERR: Error: No API URL is defined. You can configure an API URL by running "sensuctl configure"
---- End output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
Ran sensuctl create -f /etc/sensu/namespaces/test-org.json returned 1
Resource Declaration:
---------------------
# In /opt/kitchen/cache/cookbooks/sensu-go/resources/namespace.rb
45: execute "sensuctl create -f #{object_file}" do
46: action :nothing
47: end
48: end
Compiled Resource:
------------------
# Declared in /opt/kitchen/cache/cookbooks/sensu-go/resources/namespace.rb:45:in `block in class_from_file'
execute("sensuctl create -f /etc/sensu/namespaces/test-org.json") do
action [:nothing]
default_guard_interpreter :execute
command "sensuctl create -f /etc/sensu/namespaces/test-org.json"
backup 5
declared_type :execute
cookbook_name "sensu_test"
domain nil
user nil
end
System Info:
------------
chef_version=14.5.0
platform=ubuntu
platform_version=18.04
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/embedded/bin/chef-client
executable=/opt/chef/embedded/bin/chef-client
================================================================================
Error executing action `create` on resource 'sensu_namespace[test-org]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] (/opt/kitchen/cache/cookbooks/sensu-go/resources/namespace.rb line 45) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
STDOUT:
STDERR: Error: No API URL is defined. You can configure an API URL by running "sensuctl configure"
---- End output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
Ran sensuctl create -f /etc/sensu/namespaces/test-org.json returned 1
Resource Declaration:
---------------------
# In /opt/kitchen/cache/cookbooks/sensu_test/recipes/default.rb
12: sensu_namespace 'test-org' do
13: action :create
14: end
15:
Compiled Resource:
------------------
# Declared in /opt/kitchen/cache/cookbooks/sensu_test/recipes/default.rb:12:in `from_file'
sensu_namespace("test-org") do
action [:create]
updated true
updated_by_last_action true
default_guard_interpreter :default
declared_type :sensu_namespace
cookbook_name "sensu_test"
recipe_name "default"
end
System Info:
------------
chef_version=14.5.0
platform=ubuntu
platform_version=18.04
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/embedded/bin/chef-client
executable=/opt/chef/embedded/bin/chef-client
Running handlers:
[2019-10-26T02:51:59+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-10-26T02:51:59+00:00] ERROR: Exception handlers complete
Chef Client failed. 18 resources updated in 21 seconds
[2019-10-26T02:51:59+00:00] FATAL: Stacktrace dumped to /opt/kitchen/cache/chef-stacktrace.out
[2019-10-26T02:51:59+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-10-26T02:51:59+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: sensu_namespace[test-org] (sensu_test::default line 12) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[sensuctl create -f /etc/sensu/namespaces/test-org.json] (/opt/kitchen/cache/cookbooks/sensu-go/resources/namespace.rb line 45) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
STDOUT:
STDERR: Error: No API URL is defined. You can configure an API URL by running "sensuctl configure"
---- End output of sensuctl create -f /etc/sensu/namespaces/test-org.json ----
Ran sensuctl create -f /etc/sensu/namespaces/test-org.json returned 1
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Converge failed on instance <default-ubuntu-1804>. Please see .kitchen/logs/default-ubuntu-1804.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
This leads me to believe this guard was likely put in to try and put a guard around some order dependency operations but that masked a problem rather than doing what it was intended.
I can do a little investigation for this one
The actual issue being obscured here is that we really only safely support initial configuration using the sensu_ctl
resource and probably don't safely support reconfiguring any options.
This gets into some of the same issues as #43 when it comes to how to safely handle not leaking the username/password if they are under management by a chef resource.
I can start a change that at least allows reconfiguring the backend url and we can have some discussion around that with ideas.
I was wondering how much of an issue this is now that sensu no longer ships with a default password. We should probably for the moment at least call this out as a known limitation in the cookbook in that it will not support reconfiguring until we get this worked out. Thoughts?
I'm unable to reproduce this with latest versions of sensu.
After running kitchen converge default-ubuntu-1804
twice on master I have these files created:
root@dokken:~# ll .config/sensu/sensuctl/
total 16
drwxr-xr-x 2 root root 4096 Oct 25 23:30 ./
drwxr-xr-x 3 root root 4096 Oct 25 23:30 ../
-rw-r--r-- 1 root root 863 Oct 25 23:30 cluster
-rw-r--r-- 1 root root 51 Oct 25 23:30 profile
Closing now as part of issue cleanup, but please re-open with any additional information as needed and I can investigate!
I seem to remember that with a vagrant kitchen, the files ended up in /home/vagrant/.config instead of /root/.config, presumably because the sudo call leaves enough of the vagrant user's environment intact for sensuctl to pick the wrong path. You would only see that when using kitchen with vagrant.