*SOLUTION FOUND*Sorry I'm very stupid and I shouldn't work at night. The problem is that postgresql_query is new in version 2.8 in development, and I have 2.7.10 Thank you for your time
Il giorno venerdì 3 maggio 2019 21:52:58 UTC+2, magn...@gmail.com ha scritto: > > Hi, I have to create and populate a DB with Ansible. > I successfully create the db, but when I add the postgresql_query I got > syntax error. > I also tried to add the code from documentation (here > <https://docs.ansible.com/ansible/devel/modules/postgresql_query_module.html>) > > but it get the same. > > The *error* is: > >> The offending line appears to be: >> >> - name: Run queries from SQL script >> ^ here > > > > I put here the playbook, I really have any idea what it could be. Is it a > bug? > >> >>> - hosts: vm_database >> >> become: yes >> >> vars: >> >> #usate per il lancio senza Cloudify >> >> an_db_name: db_webserver >> >> #an_db_user: webserver >> >> #an_db_password: webserver >> >> tasks: >> >> - name: PostgreSQL installation... >> >> become_user: root >> >> package: >> >> name: "{{ item }}" >> >> state: present >> >> loop: >> >> - postgresql >> >> #- postgresql-contrib >> >> #- libpq-dev >> >> - python-psycopg2 >> >> >>> - name: Check Cluster dir is empty.. >> >> register: foundFiles >> >> find: >> >> paths: /var/lib/postgres/data >> >> patterns: '*.*' >> >> >>> - name: Launching initdb ... >> >> when: foundFiles.matched == 0 >> >> become_user: postgres >> >> become_flags: -i >> >> shell: initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data' >> >> >>> - name: Set postgresql.conf to allow remote connection... >> >> become_user: root >> >> lineinfile: >> >> path: /var/lib/postgres/data/postgresql.conf >> >> regexp: "^#listen_addresses = 'localhost'" >> >> line: "listen_addresses = '*' " >> >> >>> - name: Set pg_hba.conf to allow remote connection... >> >> become_user: root >> >> lineinfile: >> >> path: /var/lib/postgres/data/pg_hba.conf >> >> regexp: 'host.*all.*all.*0.0.0.0/0.*md5' #da sistemare, non >>> funziona >> >> firstmatch: yes >> >> insertafter: '^# IPv4 local connections:*' >> >> line: "host\tall\t\tall\t\t0.0.0.0/0\t\tmd5" #controllare >>> -> bazooka >> >> >>> - name: Service launch.. >> >> become_user: root >> >> service: >> >> name: postgresql >> >> state: started >> >> enabled: yes >> >> >>> - name:DB creation.. >> >> become_user: postgres >> >> postgresql_db: >> >> name: "{{ an_db_name }}" >> >> encoding: UTF-8 >> >> lc_collate: it_IT.UTF-8 >> >> lc_ctype: it_IT.UTF-8 >> >> template: template0 >> >> state: present >> >> >>> - name: User creation.. >> >> become_user: postgres >> >> postgresql_user: >> >> db: "{{ an_db_name }}" >> >> name: "{{ an_db_user }}" >> >> password: "{{ an_db_password }}" >> >> priv: ALL >> >> role_attr_flags: LOGIN,CREATEDB >> >> state: present >> >> ###EVERYTHING FINE TILL HERE#### >> >> *- name: Run queries from SQL script...* >> >> * become_user: postgres* >> >> * postgresql_query:* >> >> * db: "{{ an_db_name }}"* >> >> * path_to_script: Resource/00-create.sql* >> >> * positional_args: 1* >> >> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/718f0f2a-6c27-4dae-9ed1-9853304d7b1a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.