rsync -av ansible/roles/manifests %{buildroot}/%{_roles_path}/
rsync -av ansible/roles/nodeconf %{buildroot}/%{_roles_path}/
rsync -av ansible/roles/pre_config_all %{buildroot}/%{_roles_path}/
+rsync -av ansible/roles/log %{buildroot}/%{_roles_path}/
+
mkdir -p %{buildroot}%/%{_bootstrapping_path}/
%define RPM_NAME caas-%{COMPONENT}
%define RPM_MAJOR_VERSION 1.0.0
%define RPM_MINOR_VERSION 7
-%define KUBELET_PLUGINS_LOGDIR /var/log/kubelet-plugins/
Name: %{RPM_NAME}
Version: %{RPM_MAJOR_VERSION}
%install
mkdir -p %{buildroot}/%{_caas_libexec_path}/
-# --------------------------- LOG
-mkdir -p %{buildroot}/etc/logrotate.d/
-install -m 0640 utils/log/kubelet-plugins %{buildroot}/etc/logrotate.d/
-sed -i -e 's|{{ kubelet_plugings_log_dir }}|%{KUBELET_PLUGINS_LOGDIR}|g' %{buildroot}/etc/logrotate.d/kubelet-plugins
# --------------------------- DEPLOY
install -m 0700 utils/deploy/merge_image.sh %{buildroot}/%{_caas_libexec_path}/
mkdir -p %{buildroot}/etc/systemd/system/
%files
%{_caas_libexec_path}/merge_image.sh
-/etc/logrotate.d/kubelet-plugins
%exclude %{_caas_libexec_path}/*pyc
%exclude %{_caas_libexec_path}/*pyo
%preun
%post
-# --------------------------- LOG
-mkdir -p %{KUBELET_PLUGINS_LOGDIR}/
-grep "#CaaS CUSTOM BEGIN" /etc/logrotate.d/syslog > /dev/null;
-if [ $? -eq 0 ]; then
- sed -i -e '/#CaaS CUSTOM BEGIN/,/#CaaS CUSTOM END/d' /etc/logrotate.d/syslog
-fi
-sed -i -e '/.*missingok/i #CaaS CUSTOM BEGIN\n hourly\n size 50\n#CaaS CUSTOM END' /etc/logrotate.d/syslog
# --------------------------- DEPLOY
find /usr/lib/debug/usr/ -xtype l -exec rm -f {} \;
-# --------------------------- COMMON
%postun
-# If not upgrade, revert all CaaS related cusotmization
-if [ $1 == 0 ]; then
-
-# --------------------------- LOG
- sed -i -e '/#CaaS CUSTOM BEGIN/,/#CaaS CUSTOM END/d' /etc/logrotate.d/syslog
-/usr/bin/systemctl daemon-reload
-# --------------------------- DEPLOY
-# --------------------------- COMMON
-fi
%clean
become: true
become_user: "{{ users.admin_user_name }}"
roles:
+ - log
- pre_config_all
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- name: create logrotate directory
+ file:
+ path: "/etc/logrotate.d/"
+ state: directory
+ become: true
+ become_user: "root"
+
+- name: create the kubelet plugins log directory
+ file:
+ path: "{{ caas.kubelet_plugins_log_dir }}"
+ state: directory
+ become: true
+ become_user: "root"
+
+- name: template kubelet-plugins to logrotate directory
+ template:
+ src: kubelet-plugins
+ dest: /etc/logrotate.d/kubelet-plugins
+ mode: 0640
+ become: true
+ become_user: "root"
+
+- name: Ansible insert a line before example
+ blockinfile:
+ dest: /etc/logrotate.d/syslog
+ marker: "# CaaS CUSTOM {mark}"
+ block: |
+ hourly
+ size 50
+ insertbefore: .*missingok
+ become: true
+ become_user: "root"
+
+- name: daemon reload
+ command: /usr/bin/systemctl daemon-reload
+ become: true
+ become_user: "root"
-{{ kubelet_plugings_log_dir }}/*.log {
+"{{ caas.kubelet_plugins_log_dir }}"/*.log {
rotate 20
maxage 30
missingok
}
# TODO: clean up config when logrotate 3.10 is available https://superuser.com/questions/1059033/logrotate-wildcard-fails-on-missing-files-with-missingok-and-olddir
-# TODO: check /var/lib/kubelet/plugins/**/*.log with newer version of logrotate
-/var/lib/kubelet/plugins/*log /var/lib/kubelet/plugins/*/*log /var/lib/kubelet/plugins/*/*/*log /var/lib/kubelet/plugins/*/*/*/*log {
+# TODO: check "{{ caas.kubelet_root_directory }}"/plugins/**/*.log with newer version of logrotate
+"{{ caas.kubelet_root_directory }}"/plugins/*log "{{ caas.kubelet_root_directory }}"/plugins/*/*log "{{ caas.kubelet_root_directory }}"/plugins/*/*/*log "{{ caas.kubelet_root_directory }}"/plugins/*/*/*/*log {
size 100M
missingok
copytruncate
sharedscripts
postrotate
- rotated_logs="$(find /var/lib/kubelet/plugins -name '*.log.[1-20]')"
+ rotated_logs="$(find "{{ caas.kubelet_root_directory }}"/plugins -name '*.log.[1-20]')"
for file in $rotated_logs; do
log_file_name="$(basename $file | sed -r 's/.[0-9]+$//')"
- mv $file {{ kubelet_plugings_log_dir }}/$log_file_name
+ mv $file "{{ caas.kubelet_plugins_log_dir }}"/$log_file_name
done
endscript
}
salt: malaise68Adroitness44Gradate45Probe41Settle46Newsweek93restrict8Thirsty35abused9Pluperfect
max_login_time: 30
max_parallel_session: 15
+kubelet_root_directory: "/home/kubelet"
+kubelet_plugins_log_dir: "/var/log/kubelet-plugins/"
ansible_success: 'Ansible deploy END success'
docker_directory: /var/lib/docker
cert_directory: /etc/docker