1 Star 0 Fork 0

英拿科技/ina_system_patch_update

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
site.yml 2.83 KB
一键复制 编辑 原始数据 按行查看 历史
liliangct 提交于 2022-08-11 10:05 . init
---
- 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/inaservice/ina_system_patch_update.git
git@gitee.com:inaservice/ina_system_patch_update.git
inaservice
ina_system_patch_update
ina_system_patch_update
master

搜索帮助