使用ansible创建wordpress用户创建者

时间:2015-07-07 17:26:22

标签: wordpress automation ansible

我的脚本正常工作,它看起来像这样:

- name: create a test user
  shell: /usr/local/bin/wp/wp-cli.phar user create {{ item.name }} {{ item.email }} --user_pass={{ item.password }} --role={{ item.role }} --path=/var/www/wp
  with_items:
     - { name: 'testuser1', email: 'testuser1@123.com', password: 123, role: author }
     - { name: 'testuser2', email: 'testuser2@123.com', password: 123, role: author }

这适用于创建wordpress用户,但我想知道是否有办法在with_items中获取信息并将其移动到仅包含用户名和信息的单独文件中?

1 个答案:

答案 0 :(得分:0)

variable file (referenced with vars_files)中:

users:
  - name: testuser1
    email: testuser1@123.com
    password: 123
    role: author
  - name: testuser2
    email: testuser2@123.com
    password: 123
    role: author

然后:

- name: create a test user
  shell: /usr/local/bin/wp/wp-cli.phar user create {{ item.name }} {{ item.email }} --user_pass={{ item.password }} --role={{ item.role }} --path=/var/www/wp
  with_items: "{{users}}"