{"id":21863184,"url":"https://github.com/shfshanyue/ansible-op","last_synced_at":"2025-07-09T19:39:01.755Z","repository":{"id":86538725,"uuid":"81402207","full_name":"shfshanyue/ansible-op","owner":"shfshanyue","description":"山月的服务器配置 ansible 脚本","archived":false,"fork":false,"pushed_at":"2023-07-04T14:56:30.000Z","size":10081,"stargazers_count":30,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T08:11:12.263Z","etag":null,"topics":["ansible"],"latest_commit_sha":null,"homepage":"https://shanyue.tech/op/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shfshanyue.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-09T02:58:49.000Z","updated_at":"2024-10-17T12:35:47.000Z","dependencies_parsed_at":"2023-03-13T19:58:50.549Z","dependency_job_id":"43020af5-8eeb-4ed2-a2db-d1b8efe6be55","html_url":"https://github.com/shfshanyue/ansible-op","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shfshanyue%2Fansible-op","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shfshanyue%2Fansible-op/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shfshanyue%2Fansible-op/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shfshanyue%2Fansible-op/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shfshanyue","download_url":"https://codeload.github.com/shfshanyue/ansible-op/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248950021,"owners_count":21188195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible"],"created_at":"2024-11-28T03:20:25.876Z","updated_at":"2025-04-14T19:44:34.816Z","avatar_url":"https://github.com/shfshanyue.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 个人常用 ansible 脚本\n\n## 快速开始\n\n``` bash\n# 安装依赖\n$ ansible-galaxy install -r requirements.yml\n\n# 安装某一个 playbook\n$ ansible-playbook -i hosts git.yml\n\n# 指定某一台测试服务器，一键安装\n$ ansible-playbook -i hosts --limit=op prepare.yml git.yml tmux.yml vim.yml language.yml zsh.yml\n```\n\n## Q\u0026A\n\n### 如何得知所有的目标机器是否可达\n\n``` bash\n$ ansibel all -m ping\n```\n\n### 如何得知所有的目标机器的发行版\n\n``` bash\n$ ansible all -m setup\n```\n\n### 如何在所有目标机器上执行命令\n\n``` bash\n$ ansible all -a pwd\n```\n\n### 如何根据条件执行 Task\n\n``` bash\n# 当在国内时，选择阿里云镜像\n- name: add docker repo -\u003e aliyun\n  shell: yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo\n  when: ansible_date_time.tz_offset == \"+0800\"\n  args:\n    creates: /etc/yum.repos.d/docker-ce.repo \n```\n\n### 如何忽略错误使 Task 继续执行下去\n\n`ignore_errors: true`\n\n\n### 如何根据一个 task 的执行结果来决定是否执行其它 task\n\n使用 `register` 来监听当前任务的执行情况，使用 `when` 设定条件\n\n### 为什么使用 git，file 等模块比直接执行 shell 要好些\n\ngit，file 能够更好地满足幂等性\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshfshanyue%2Fansible-op","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshfshanyue%2Fansible-op","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshfshanyue%2Fansible-op/lists"}