# 安装依赖
$ ansible-galaxy install -r requirements.yml
# 安装某一个 playbook
$ ansible-playbook -i hosts git.yml
# 指定某一台测试服务器,一键安装
$ ansible-playbook -i hosts --limit=op prepare.yml git.yml tmux.yml vim.yml language.yml zsh.yml
$ ansibel all -m ping
$ ansible all -m setup
$ ansible all -a pwd
# 当在国内时,选择阿里云镜像
- name: add docker repo -> aliyun
shell: yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
when: ansible_date_time.tz_offset == "+0800"
args:
creates: /etc/yum.repos.d/docker-ce.repo
ignore_errors: true
使用 register
来监听当前任务的执行情况,使用 when
设定条件
git,file 能够更好地满足幂等性