Guest User

Untitled

a guest
Feb 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. ---
  2. - hosts: test
  3. remote_user: frolov
  4. become: yes
  5. # become_method: sudo
  6. #
  7. tasks:
  8. - name: Debug
  9. debug: msg={{ ansible_os_family }}
  10.  
  11. - set_fact: package_name=apache2
  12. when: ansible_os_family == "Debian"
  13.  
  14. - set_fact: package_name=httpd
  15. when: ansible_os_family == "Redhat"
  16.  
  17.  
  18. - name: Update cache packages
  19. apt:
  20. update_cache: yes
  21. cache_valid_time: 3600
  22. # #
  23. # - name: Final_packet
  24. # debug: msg={{ package_name }}
  25.  
  26. - name: Install Apache2
  27. apt:
  28. name: "{{ item }}"
  29. state: latest
  30. with_items:
  31. - "{{ package_name }}"
  32. when: ansible_os_family == "Debian"
  33.  
  34. - name: Install httpd2
  35. apt:
  36. name: "{{ item }}"
  37. state: latest
  38. with_items:
  39. - "{{ package_name }}"
  40. when: ansible_os_family == "Redhat"
  41.  
  42. fatal: [10.101.251.157]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefinednnThe error appears to have been in '/etc/ansible/playbook/apache_install.yml': line 26, column 5, but maynbe elsewhere in the file depending on the exact syntax problem.nnThe offending line appears to be:nnn - name: Install Apache2n ^ herennexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>nexception: 'item' is undefined"}
  43. to retry, use: --limit @/etc/ansible/playbook/apache_install.retry
  44.  
  45. ---
  46.  
  47. - name: install php5.6
  48. include_tasks: centos_php56.yml
  49. when: (ansible_distribution == "CentOS") and (php.version == "5.6")
  50.  
  51. - name: install php7.0
  52. include_tasks: centos_php70.yml
  53. when: (ansible_distribution == "CentOS") and (php.version == "7.0")
  54.  
  55. - name: install php56
  56. yum: name={{ item }} state=latest
  57. with_items:
  58. - php56w
  59. - php56w-opcache
  60. - php56w-pdo
  61. - php56w-mysql
  62. - php56w-mbstring
  63. - php56w-mcrypt
  64. - php56w-pear
  65. - php56w-pecl-apcu
  66. - php56w-gd
  67. notify: restart httpd
  68.  
  69. - name: install php
  70. yum: name=php state=latest
  71. notify: restart httpd
  72.  
  73. - set_fact:
  74. package_name=git
  75. - name: yum install packages
  76. yum:
  77. name: "{{ package_name }}"
  78. state: latest
  79. when:
  80. ansible_os_family == "Centos"
  81.  
  82. TASK [git : yum install packages]
  83. **********************************************
  84. fatal: [server.company.tld]: FAILED! => {"changed": false, "failed": true, "msg": "Unsupported parameters for (yum) module: when Supported parameters include: allow_downgrade,conf_file,disable_gpg_check,disablerepo,enablerepo,exclude,install_repoquery,installroot,list,name,security,skip_broken,state,update_cache,validate_certs"}
  85.  
  86. ---
  87.  
  88. - name: yum install packages
  89. yum:
  90. name: git
  91. state: latest
  92. when:
  93. ansible_os_family == "Centos"
  94.  
  95. ---
  96.  
  97. - set_fact:
  98. package_name="git"
  99. - name: yum install packages
  100. yum:
  101. name: "{{ item }}"
  102. state: latest
  103. with_items:
  104. - "{{ package_name }}"
Add Comment
Please, Sign In to add comment