Guest User

Untitled

a guest
Feb 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. - hosts: test
  2. remote_user: admin
  3. become: yes
  4.  
  5. tasks:
  6. - name: Debug
  7. debug: msg={{ ansible_os_family }}
  8.  
  9. - set_fact: package_name=apache2
  10. when: ansible_os_family == "Debian"
  11.  
  12. - set_fact: package_name=httpd
  13. when: ansible_os_family == "Redhat"
  14.  
  15.  
  16. - name: Update cache packages
  17. apt:
  18. update_cache: yes
  19. cache_valid_time: 3600
  20.  
  21.  
  22. - name: Install Apache2
  23. apt:
  24. name: {{ package_name }}
  25. state: latest
  26. when: ansible_os_family == "Debian"
  27.  
  28. - name: Install httpd
  29. yum:
  30. name: {{ package_name }}
  31. state: latest
  32. when: ansible_os_family == "RedHat"
  33.  
  34. apt:
  35. name: {{ package_name }}
  36. ^ here
  37. We could be wrong, but this one looks like it might be an issue with
  38. missing quotes. Always quote template expression brackets when they
  39. start a value. For instance:
  40.  
  41. with_items:
  42. - {{ foo }}
  43.  
  44. Should be written as:
  45.  
  46. with_items:
  47. - "{{ foo }}"
  48.  
  49. - name: Install Apache2
  50. apt:
  51. name: "{{ package_name }}"
  52.  
  53. ---
  54.  
  55. - name: install php5.6
  56. include_tasks: centos_php56.yml
  57. when: (ansible_distribution == "CentOS") and (php.version == "5.6")
  58.  
  59. - name: install php7.0
  60. include_tasks: centos_php70.yml
  61. when: (ansible_distribution == "CentOS") and (php.version == "7.0")
  62.  
  63. - name: install php56
  64. yum: name={{ item }} state=latest
  65. with_items:
  66. - php56w
  67. - php56w-opcache
  68. - php56w-pdo
  69. - php56w-mysql
  70. - php56w-mbstring
  71. - php56w-mcrypt
  72. - php56w-pear
  73. - php56w-pecl-apcu
  74. - php56w-gd
  75. notify: restart httpd
  76.  
  77. - name: install php
  78. yum: name=php state=latest
  79. notify: restart httpd
Add Comment
Please, Sign In to add comment