不推荐使用裸变量php Ansible

时间:2016-12-28 11:12:08

标签: php ansible devops pecl

我有这个ansible任务

- name: Install
  apt: pkg="php7.0-dev" state=present
  when: php.pecl_packages is defined

- name: Install Package
  shell: echo "\n\n\n\n\n\n\n\n\n" | pecl install {{ item }}
  register: pecl_result
  changed_when: "'already installed' not in pecl_result.stdout"
  failed_when: "pecl_result.stderr or ('ERROR' in pecl_result.stdout)"
  with_items: php.pecl_packages
  when: php.pecl_packages is defined

- name: Create extension .ini file
  template: >
    src="extension.tpl"
    dest="/etc/php/7.0/mods-available/{{ item }}.ini"
    owner="root"
    group="root"
    mode=0644
  with_items: php.pecl_packages
  when: php.pecl_packages is defined

- name: Enable extension
  shell: Php7enmod {{ item }}
  with_items: php.pecl_packages
  when: php.pecl_packages is defined

和默认/ main.yml为

php:
    install: '1'
    packages: [php7.0-mcrypt]
    peclpackages: [hash]

和templates / extension.tpl为

; Configuration for php PECL {{ item }} extension
extension={{ item }}.so

我还在,裸变量被弃用异常,我怎么能这样做?

  

[DEPRECATION WARNING]:不推荐使用裸变量。更新你的   playbooks使环境值使用完整的变量语法   ( '{{php.pecl_packages}}')。

1 个答案:

答案 0 :(得分:1)

您可能想要搜索" ansible bare变量"在SO或谷歌......

而不是with_items: php.pecl_packages使用with_items: "{{php.pecl_packages}}"