代码拉取完成,页面将自动刷新
---
- hosts: all
gather_facts: true
# vars_prompt:
# - name: PackagesVersion
# prompt: "Is it the output you want?"
# private: no
# default: "yes"
tasks:
# preparation process
- name: add repo rhel7u8_Fix
yum_repository:
name: rhel7u8_Fix
description: "Network_RHEL7.8_Fix"
baseurl: "http://172.31.130.104/repos/x64/rhel7u8/Fix/{{ update_time }}"
gpgcheck: no
enabled: yes
- name: clean yum repo
command: yum clean all
args:
warn: false
# updating process
- name: check packages for updates
shell: yum list updates | awk 'f;/Updated Packages/{f=1;}' | awk '{ print $1 }'
changed_when: updates.stdout_lines | length > 0
args:
warn: false
register: updates
- name: display packages for updates count
debug:
msg: "found {{ updates.stdout_lines | length }} packages to be updated:\n\n{{ updates.stdout }}"
# - name: Is it the output you want?
# debug:
# msg: '{{ PackagesVersion }}'
- name: you need to confirm
pause:
minutes: "{{ wait_time_minutes }}"
prompt: |
Notice: 1.1> If the above output is correct by Ansible CLI, please continue, Press 【Ctrl+c】, Then Press 【c】
1.2> If the above output is correct by 【Ansible Tower】, please Waiting Time 【"{{ wait_time_minutes }}"minutes】 automatically continue
2.1> If the above output is error by ansible CLI, Please abort, Press 【Ctrl+c】, Then Press 【a】
2.2> if the above output is error by 【Ansible Tower】, Please 【Click the cancel button】 on the Tower interface
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
- when: updates.stdout_lines | length > 0
block:
- name: ensure passwd group is not immutable, "-i"
file:
path: "{{ item }}"
attr: -i
loop:
- /etc/passwd
- /etc/group
register: attr_file
changed_when: "'i' in attr_file.diff.before.attributes"
- name: install latest verison
yum:
name: '*'
enablerepo: rhel7u8_Fix
state: latest
update_cache: yes
register: result
- debug:
msg: '{{ item }}'
loop: '{{ result.results | from_yaml_all | list }}'
- name: ensure passwd group is immutable, "+i"
file:
path: "{{ item }}"
attr: +i
loop:
- /etc/passwd
- /etc/group
register: attr_file
changed_when: "'i' not in attr_file.diff.before.attributes"
- name: remove repo rhel7u8_Fix
yum_repository:
name: rhel7u8_Fix
state: absent
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。