标签:0.105 skipping -- changed chrony ansible 172.31
chrony客户端playbook
[root@ansible-server ansible]# cd playbook/chrony
[root@ansible-server chrony]# vars.yml
SERVER1: 172.31.0.101
SERVER2: 172.31.0.104
[root@ansible-server chrony]# vim install_chrony_client.yml
---
- hosts: chronyclient
vars_files:
vars.yml
tasks:
- name: install CentOS or Rocky chrony
yum:
name: chrony
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
- name: delete CentOS or Rocky /etc/chrony.conf file contains '^pool.*' string line
lineinfile:
path: /etc/chrony.conf
regexp: '^pool.*'
state: absent
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
notify:
- restart chronyd
- name: delete CentOS or Rocky /etc/chrony.conf file contains '^server.*' string line
lineinfile:
path: /etc/chrony.conf
regexp: '^server.*'
state: absent
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
notify:
- restart chronyd
- name: add Time server for CentOS or Rocky /etc/chrony.conf file
lineinfile:
path: /etc/chrony.conf
insertafter: '^# Please consider .*'
line: "server {{ SERVER1 }} iburst\nserver {{ SERVER2 }} iburst"
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
notify:
- restart chronyd
- name: delete lock files
file:
path: "{{ item }}"
state: absent
loop:
- /var/lib/dpkg/lock
- /var/lib/apt/lists/lock
- /var/cache/apt/archives/lock
when:
- ansible_distribution=="Ubuntu"
- name: apt update
apt:
update_cache: yes
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: install Ubuntu chrony
apt:
name: chrony
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: delete Ubuntu /etc/chrony/chrony.conf file contains '^pool.*' string line
lineinfile:
path: /etc/chrony/chrony.conf
regexp: '^pool.*'
state: absent
when:
- ansible_distribution=="Ubuntu"
notify:
- restart chronyd
- name: add Time server for Ubuntu /etc/chrony/chrony.conf file
lineinfile:
path: /etc/chrony/chrony.conf
insertafter: '^# See http:.*'
line: "server {{ SERVER1 }} iburst\nserver {{ SERVER2 }} iburst"
when:
- ansible_distribution=="Ubuntu"
notify:
- restart chronyd
- name: start chronyd
systemd:
name: chronyd
state: started
enabled: yes
handlers:
- name: restart chronyd
service:
name: chronyd
state: restarted
[root@ansible-server chrony]# cd ../../
[root@ansible-server ansible]# ansible-playbook playbook/chrony/install_chrony_client.yml
PLAY [chronyclient] ***************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************
ok: [172.31.0.103]
ok: [172.31.0.105]
ok: [172.31.0.102]
TASK [install CentOS or Rocky chrony] *********************************************************************************************************
skipping: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
TASK [delete CentOS or Rocky /etc/chrony.conf file contains '^pool.*' string line] ************************************************************
skipping: [172.31.0.105]
ok: [172.31.0.103]
changed: [172.31.0.102]
TASK [delete CentOS or Rocky /etc/chrony.conf file contains '^server.*' string line] **********************************************************
skipping: [172.31.0.105]
changed: [172.31.0.103]
ok: [172.31.0.102]
TASK [add Time server for CentOS or Rocky /etc/chrony.conf file] ******************************************************************************
skipping: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
TASK [delete lock files] **********************************************************************************************************************
skipping: [172.31.0.102] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.102] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.102] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.103] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.103] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.103] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.105] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.105] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.105] => (item=/var/cache/apt/archives/lock)
TASK [apt update] *****************************************************************************************************************************
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
TASK [install Ubuntu chrony] ******************************************************************************************************************
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
TASK [delete Ubuntu /etc/chrony/chrony.conf file contains '^pool.*' string line] **************************************************************
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
TASK [add Time server for Ubuntu /etc/chrony/chrony.conf file] ********************************************************************************
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
TASK [start chronyd] **************************************************************************************************************************
changed: [172.31.0.103]
ok: [172.31.0.105]
changed: [172.31.0.102]
RUNNING HANDLER [restart chronyd] *************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.102]
PLAY RECAP ************************************************************************************************************************************
172.31.0.102 : ok=7 changed=5 unreachable=0 failed=0 skipped=5 rescued=0 ignored=0
172.31.0.103 : ok=7 changed=5 unreachable=0 failed=0 skipped=5 rescued=0 ignored=0
172.31.0.105 : ok=8 changed=6 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
[root@centos8-client ~]# chronyc sources -nv
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.31.0.101 3 6 17 55 +708us[ +788us] +/- 28ms
^+ 172.31.0.104 3 6 17 55 -902us[ -902us] +/- 32ms
[root@centos7-client ~]# chronyc sources -nv
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.31.0.101 3 6 17 9 -522us[ -526us] +/- 34ms
^+ 172.31.0.104 3 6 17 10 +590us[ +590us] +/- 35ms
root@ubuntu2004-client:~# chronyc sources -nv
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.31.0.101 3 6 17 52 -483us[ -400us] +/- 33ms
^+ 172.31.0.104 3 6 17 52 +169us[ +252us] +/- 34ms
标签:0.105,skipping,--,changed,chrony,ansible,172.31 来源: https://blog.csdn.net/qq_25599925/article/details/122170914
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。