从master端拷贝yum源目录到minion
# salt '*' cp.get_dir salt://repo/ /etc/yum.repos.d/
写repo.sls配置
[root@salt-master salt]# more repo.sls/etc/yum.repos.d/epel.repo: #配置文件名称 file.managed: #文件管理 - source: salt://repo/epel.repo #源文件,需要更改好,会更新给minion - mode: 755 #权限 - user: root - group: root
查看已修改好的文件
[root@salt-master salt]# more repo/epel.repo[epel]name=Extra Packages for Enterprise Linux 6 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6[epel-debuginfo]name=Extra Packages for Enterprise Linux 6 - $basearch - Debug#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debugmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=0[epel-source]name=Extra Packages for Enterprise Linux 6 - $basearch - Source#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMSmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=0
执行更新操作
[root@salt-master salt]# salt '*' state.sls repoSolrCloud-node5:---------- State: - file Name: /etc/yum.repos.d/epel.repo Function: managed Result: True Comment: File /etc/yum.repos.d/epel.repo is in the correct state Changes: Summary------------Succeeded: 1Failed: 0------------Total: 1SolrCloud-node4:---------- State: - file Name: /etc/yum.repos.d/epel.repo Function: managed Result: True Comment: File /etc/yum.repos.d/epel.repo is in the correct state Changes: Summary------------Succeeded: 1Failed: 0------------Total: 1SolrCloud-node3:---------- State: - file Name: /etc/yum.repos.d/epel.repo Function: managed Result: True Comment: File /etc/yum.repos.d/epel.repo is in the correct state Changes: Summary------------Succeeded: 1Failed: 0------------Total: 1
查看更新的是否成功
[root@salt-master salt]# salt '*' cmd.run "grep 'gpgcheck=0' /etc/yum.repos.d/epel.repo"SolrCloud-node4: gpgcheck=0 gpgcheck=0 gpgcheck=0SolrCloud-node3: gpgcheck=0 gpgcheck=0 gpgcheck=0SolrCloud-node5: gpgcheck=0 gpgcheck=0 gpgcheck=0