Skip to content

Instantly share code, notes, and snippets.

@ryanvgates
ryanvgates / code.rb
Created November 22, 2021 21:42
Chef hardening_rul ip range solution
hardening_rule "Open outbound port #{p} in firewall for Isilon at #{node[:server][:ip_range].gsub("/","-")}" do
direction :out
protocol :udp
port p
destination "#{node[:server][:ip_range]}"
end
@ryanvgates
ryanvgates / output.txt
Created November 22, 2021 21:39
Chef hardening_rule ip range gotcha error
[2021-11-16T16:36:47+00:00] ERROR: Running exception handlers
[2021-11-16T16:36:47+00:00] ERROR: Exception handlers complete
[2021-11-16T16:36:47+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2021-11-16T16:36:47+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-11-16T16:36:47+00:00] ERROR: hardening_rule[Open outbound port 140 in firewall for Isilon at 0.0.0.0/24] (cookbook::firewall line 2) had an error: Chef::Exceptions::ValidationFailed: Option name's value Open-outbound-port-140-in-firewall-at-0.0.0.0/24-udp-140-out does not match regular expression /^[-\w.]+$/
[2021-11-16T16:36:47+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)Chef::Exceptions::ValidationFailed: hardening_rule[Open outbound port 137 in firewall for Isilon at 10.99.181.0/24] (nrec_snapshot_agent::firewall line 2) had an error: Chef::Exceptions::ValidationFailed: Option name's value Open-outbound-port-140-in-
@ryanvgates
ryanvgates / code.rb
Created November 22, 2021 21:34
Chef hardening_rule ip range gotcha code
hardening_rule "Open outbound port #{p} in firewall at #{node[:server][:ip_range]}" do
direction :out
protocol :udp
port p
destination "#{node[:server][:ip_range]}"
end
@ryanvgates
ryanvgates / install_as_service.sh
Created November 1, 2021 21:00
Installing Monit as a Service
!/bin/sh
sudo apt install monit && \
sudo systemctl enable monit
@ryanvgates
ryanvgates / commands.sh
Created October 13, 2021 19:17
ElasticSearch Upgrade Solution
cat secret_password_file | sudo -u elasticsearch -g elasticsearch /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.http.ssl.keystore.secure_password
cat secret_password_file | sudo -u elasticsearch -g elasticsearch /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.http.ssl.truststore.secure_password
cat secret_password_file | sudo -u elasticsearch -g elasticsearch /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.transport.ssl.keystore.secure_password
cat secret_password_file | sudo -u elasticsearch -g elasticsearch /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.transport.ssl.truststore.secure_password
cat secret_password_file | sudo -u elasticsearch -g elasticsearch /usr/share/elasticsearch/bin/elasticsearch-keystore add --stdin bootstrap.password
@ryanvgates
ryanvgates / output.txt
Created October 13, 2021 19:15
ElasticSearch Upgrade Error
[2020-04-07T16:02:30,991][INFO ][o.e.e.NodeEnvironment ] [search1] using [1] data paths, mounts [[/var/data/elasticsearch (/dev/vdb)]], net usable_space [4.9gb], net total_space [4.9gb], types [xfs]
[2020-04-07T16:02:30,991][INFO ][o.e.e.NodeEnvironment ] [search1] heap size [3.8gb], compressed ordinary object pointers [true]
[2020-04-07T16:02:31,035][INFO ][o.e.n.Node ] [search1] node name [search1], node ID [GqAg0wA8RyG6BI18t0bQ1w]
[2020-04-07T16:02:31,035][INFO ][o.e.n.Node ] [search1] version[6.8.5], pid[17683], build[default/deb/78990e9/2019-11-13T20:04:24.100411Z], OS[Linux/4.15.0-46-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_202/25.202-b08]
[2020-04-07T16:02:31,035][INFO ][o.e.n.Node ] [search1] JVM arguments [-Xms3988m, -Xmx3988m, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Dio.netty.noUnsafe=true, -
@ryanvgates
ryanvgates / setup_monit_for_es.sh
Created October 12, 2021 20:53
Monit for ElasticSearch
#!/bin/sh
sudo apt install monit && \
sudo systemctl enable monit && \
echo '
check process elasticsearch with pidfile /var/run/elasticsearch/elasticsearch.pid
start program = "/bin/systemctl start elasticsearch.service"
stop program = "/bin/systemctl stop elasticsearch.service"' | sudo tee /etc/monit/conf.d/elasticsearch-monitrc && \
sudo systemctl stop monit.service && \
sudo systemctl start monit.service && \
@ryanvgates
ryanvgates / script.js
Created September 7, 2021 16:01
MongoDB Long Running Query
use mydb;
rs.secondaryOk();
db.Collection.aggregate([
{
$match: {
groups: { $exists: true }
}
},
{
@ryanvgates
ryanvgates / shell.sh
Created August 24, 2021 20:09
Swift V1 Authenticate
ryan@server:~$ curl -i -H "X-Auth-User: user" -H "X-Auth-Key: password" https://swift.server.com/auth/v1.0
HTTP/1.1 200 OK
X-Storage-Url: https://swift.server.com/v1/AUTH_container
X-Auth-Token: AUTH_tkc555555555555555555555555555555
Content-Type: text/plain; charset=UTF-8
X-Storage-Token: AUTH_tkc555555555555555555555555555555
Content-Length: 0
X-Trans-Id: txe55555555555555555555-5555555555
X-Openstack-Request-Id: txe55555555555555555555-5555555555
Date: Tue, 24 Aug 2021 19:50:50 GMT
@ryanvgates
ryanvgates / shell.sh
Created August 24, 2021 20:07
Swift Authentication Error
August 20th 2021, 10:21:26.235 ERROR Error copying object : "container"/"{guid}" to : "container"/"{guid}"
August 20th 2021, 10:21:26.234 ERROR Error Swift Response: '"StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
X-Trans-Id: txe55555555555555555555-5555555555
X-Openstack-Request-Id: txe55555555555555555555-5555555555