-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCTOPUS-547: add chrony modifications to the pvs_prepare and remove_c…
…hrony changes on destroy Signed-off-by: Paul Bastide <[email protected]>
- Loading branch information
Showing
3 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################ | ||
# Copyright 2023 - IBM Corporation. All rights reserved | ||
# SPDX-License-Identifier: Apache-2.0 | ||
################################################################ | ||
|
||
# The script adds chrony. | ||
|
||
echo "Generate the configuration:" | ||
cat << EOF > vars.yaml | ||
--- | ||
subnets: | ||
EOF | ||
for SUBNET in $(ip r | grep via | grep -v default | awk '{print $1}') | ||
do | ||
cat << EOF >> vars.yaml | ||
- { subnet: '${SUBNET}'} | ||
EOF | ||
done | ||
|
||
# Backup the chronyd configuration | ||
echo "Backing up prior configs" | ||
mv /etc/chrony.conf.backup /etc/chrony.conf.backup-$(date +%s) || true | ||
cp -f /etc/chrony.conf /etc/chrony.conf.backup | ||
|
||
echo "Make the inventory file" | ||
cat << EOF > inventory | ||
[vmhost] | ||
localhost ansible_connection=local ansible_user=root | ||
EOF | ||
|
||
echo "Creating the chrony chrony.yaml" | ||
cat << EOF > chrony.yaml | ||
--- | ||
- name: chrony | ||
hosts: all | ||
tasks: | ||
- name: update chrony config | ||
ansible.builtin.replace: | ||
path: /etc/chrony.conf | ||
regexp: "# Allow NTP client access from local network.\n" | ||
replace: "# Allow NTP client access from local network.\nallow {{item.subnet}}\n" | ||
loop: "{{ subnets }}" | ||
EOF | ||
|
||
echo "Running the chronyd changes" | ||
ansible-playbook chrony.yaml [email protected] -i inventory | ||
|
||
echo "Restart chronyd" | ||
sleep 10 | ||
systemctl restart chronyd | ||
echo "Done with the chronyd" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################ | ||
# Copyright 2023 - IBM Corporation. All rights reserved | ||
# SPDX-License-Identifier: Apache-2.0 | ||
################################################################ | ||
|
||
# The script removes chrony. | ||
|
||
if [ -f /etc/chrony.conf.backup ] | ||
then | ||
echo "restoring chronyd" | ||
mv -f /etc/chrony.conf.backup /etc/chrony.conf || true | ||
fi | ||
|
||
echo "Restart chronyd" | ||
sleep 10 | ||
systemctl restart chronyd | ||
echo "Done with the chronyd" |
This file contains 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