Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - hosts: test
- remote_user: admin
- become: yes
- tasks:
- - name: Debug
- debug: msg={{ ansible_os_family }}
- - set_fact: package_name=apache2
- when: ansible_os_family == "Debian"
- - set_fact: package_name=httpd
- when: ansible_os_family == "Redhat"
- - name: Update cache packages
- apt:
- update_cache: yes
- cache_valid_time: 3600
- - name: Install Apache2
- apt:
- name: {{ package_name }}
- state: latest
- when: ansible_os_family == "Debian"
- - name: Install httpd
- yum:
- name: {{ package_name }}
- state: latest
- when: ansible_os_family == "RedHat"
- apt:
- name: {{ package_name }}
- ^ here
- We could be wrong, but this one looks like it might be an issue with
- missing quotes. Always quote template expression brackets when they
- start a value. For instance:
- with_items:
- - {{ foo }}
- Should be written as:
- with_items:
- - "{{ foo }}"
- - name: Install Apache2
- apt:
- name: "{{ package_name }}"
- ---
- - name: install php5.6
- include_tasks: centos_php56.yml
- when: (ansible_distribution == "CentOS") and (php.version == "5.6")
- - name: install php7.0
- include_tasks: centos_php70.yml
- when: (ansible_distribution == "CentOS") and (php.version == "7.0")
Add Comment
Please, Sign In to add comment