Last active
February 15, 2016 16:32
-
-
Save TanyaCouture/b5eead349fb5f7070d29 to your computer and use it in GitHub Desktop.
logrotate packaging plans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`mantl-logrotate` | |
tasks/main.yml | |
// set logrotate interval to daily | |
// in file /etc/logrotate.conf | |
// look for reg expression '^weekly' | |
// replace last matching line of reg expression with "daily" | |
packaging solutions: | |
sed 's/\(.*\)^weekly/daily/' /etc/logrotate.conf | |
// set logrotate retention period to 7 days | |
// in file /etc/logrotate.conf | |
// replace last matching line of reg expression '^rotate 4' with "rotate 7" | |
packaging solutions: | |
sed 's/\(.*\)^rotate 4/rotate 7/' /etc/logrotate.conf | |
// copy component logrotate configurations | |
// when mesos=true docker=true and in zookeeper role == 'control' | |
// copy component to logrotate configurations | |
/etc/logrotate/component | |
// set mode to 0644 | |
packaging solutions: | |
// call on script: when mesos and docker are installed on all nodes and zookeeper is on leader nodes, copy components to logrotate | |
script: | |
#!/bin/bash | |
for component in "mesos" "docker" "zookeeper"; do | |
systemctl status $component | |
if[ $? == 0 ]; then | |
cp $component /etc/logrotate/ | |
chmod 0644 /etc/logrotate/$component | |
else | |
echo $component not active | |
fi | |
done | |
// create component archives | |
// same conditions as above | |
// copy components to archives | |
// /var/log/component/archive | |
packaging solutions: | |
// call on script: when mesos and docker are installed on all nodes and zookeeper is on leader nodes, copy components to archive | |
script: | |
#!/bin/bash | |
for component in "mesos" "docker" "zookeeper"; do | |
systemctl status $component | |
if[ $? == 0 ]; then | |
sudo cp $component /var/log/$component/archive | |
sudo chmod 0644 /var/log/$component/archive | |
else | |
echo $component not active | |
fi | |
done | |
+ 3 template files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Bash, when you are making a reference to a variable, you need to append $ to it's name. But, you don't when you are assigning it.
So,
for component in blah ..
will work, butsystemctl status component
won't. It needs to besystemctl status $component
.Also, on line 14, there is a
\
right before the secondrotate
. I haven't run the code, but it looks like it won't work as intended.