创建一个用于安装Ansible的playbook
我为安装Ansible而创建了一个playbook。打算在跳板服务器等情况下使用。
- name: install python (CentOS 6)
yum: name={{item}} enablerepo=epel state=installed
with_items:
- PyYAML
- python-paramiko
- python-jinja2
when: ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0]|int == 6
tags: python
- name: install python26 (CentOS 5)
yum: name={{item}} enablerepo=epel state=installed
with_items:
- python26
- python26-PyYAML
- python26-paramiko
- python26-jinja2
when: ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0]|int == 5
tags: python
- name: git clone ansible
git: repo=git://github.com/ansible/ansible.git
dest={{ ansible_cache_dir }}/ansible
version=v1.3.1
register: git_result
- name: install ansible (CentOS 6)
shell: |
make install
chdir={{ ansible_cache_dir }}/ansible creates=/usr/bin/ansible
when: git_result.changed and ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0]|int == 6
tags: ansible
- name: install ansible (CentOS 5)
shell: |
sed -i 's/^PYTHON=.*/PYTHON=python26/' Makefile &&
make install
chdir={{ ansible_cache_dir }}/ansible creates=/usr/bin/ansible
when: git_result.changed and ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0]|int == 5
tags: ansible