Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro ao declarar variáveis

Estou tendo o erro a seguir ao declarar as variáveis:

ERROR! failed to combine variables, expected dicts but got a 'dict' and a 'AnsibleUnicode': 
{}
"wp_username = wordpress_user wp_user_password = 12345 wp_db_name = wordpress_db wp_db_ip = '172.17.177.42' wp_installation_dir = '/var/www/wordpress/' wp_host_ip = '172.17.177.40'"

Provisioning.yml:

- hosts: database
  handlers:
    - name: restart mysql
      service: 
        name: mysql
        state: restarted
      become: yes
  tasks:
    - name: 'Instala pacotes de dependencia MYSQL'
      apt:
        name: 
          - mysql-server-5.6
          - python-mysqldb
        state: latest
      become: yes

    - name: 'Cria o banco MYSQL'
      mysql_db:
        name: "{{ wp_db_name }}"
        login_user: root
        state: present

    - name: 'Cria um usuário MYSQL'
      mysql_user:
        login_user: root
        name: "{{ wp_username }}"
        password: "{{ wp_user_password }}"
        priv: "{{ wp_db_name }}.*:ALL"
        state: present
        host: "{{ item }}"
      with_items:
        - 'localhost'
        - '127.0.0.1'
        - "{{ wp_host_ip }}"

    - name: 'Configura MySQL para aceitar conexões remotas'
      copy:
        src: 'files/my.cnf'
        dest: '/etc/mysql/my.cnf'
      become: yes
      notify:
        - restart mysql

- hosts: wordpress
  handlers:
    - name: restart apache
      service: 
        name: apache2
        state: restarted
      become: yes
  tasks:
    - name: 'Instala pacotes de dependencia'
      apt:
        name: 
          - php5
          - apache2
          - libapache2-mod-php5
          - php5-gd
          - libssh2-php
          - php5-mysql
        state: latest
      become: yes

    - name: 'Baixa o arquivo de instalacao do Wordpress'
      get_url:
        url: 'https://wordpress.org/wordpress-5.0.tar.gz'
        dest: '/tmp/wordpress.tar.gz'

    - name: 'Descompacta o zip wordpress'
      unarchive:
        src: '/tmp/wordpress.tar.gz'
        dest: '/var/www/'
        remote_src: yes
      become: yes

    - copy:
        src: "{{ wp_installation_dir }}/wp-config-sample.php"
        dest: "{{ wp_installation_dir }}/wp-config.php"
        remote_src: yes
      become: yes

    - name: 'Configura o wp-config com as entradas do banco de dados'     
      replace:
        path: "{{ wp_installation_dir }}/wp-config.php"
        regexp: "{{ item.regex }}"
        replace: "{{ item.value }}"
        backup: yes
      with_items:
        - { regex: 'database_name_here', value: "{{ wp_db_name }}"}
        - { regex: 'username_here', value: "{{ wp_username }}"}
        - { regex: 'password_here', value: "{{ wp_user_password }}"}
        - { regex: 'localhost', value: "{{ wp_db_ip }}"}
      become: yes

    - name: 'Configura apontamento do apache para WordPress'
      copy:
        src: 'files/000-default.conf'
        dest: '/etc/apache2/sites-available/000-default.conf'
      become: yes
      notify:
        - restart apache

all.yml:

wp_username = wordpress_user
wp_user_password = 12345
wp_db_name = wordpress_db
wp_db_ip = '172.17.177.42'
wp_installation_dir = '/var/www/wordpress/'
wp_host_ip = '172.17.177.40'

Alguém pode me dar uma luz?

2 respostas
solução!

Obs: podem fechar o tópico. Identifiquei que estava usando "=" ao invés de ":" no all.yml.

Abs.

Olá, André. Tudo bem?

Fico contente que você tenha conseguido resolver o problema.

Bons estudos!