Advertisement
freephile

ansible variable undefined

Sep 10th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.10 KB | None | 0 0
  1. ####### Playbook provision.yml ###################
  2.  
  3. - hosts: mw_hosts
  4.   # use strategy: debug when you want to debug your playbook
  5.   strategy: debug
  6.  
  7.   gather_facts: no
  8.  
  9.   vars_files:
  10.    - defaults/main.yml
  11.     - vars.yml
  12.  
  13.   pre_tasks:
  14.     - name: Record hostname if not defined
  15.       set_fact:
  16.         wiki_hostname: "{{ inventory_hostname }}"
  17.         when: wiki_hostname is undefined
  18.     - name: Wait for new host to come up
  19.       local_action: wait_for host={{ ansible_ssh_host }} port=22 state=started delay=0
  20.       tags: [connect]
  21.     - setup:
  22.     - include: tasks/swap.yml
  23.       tags: [whitebox, disk]
  24.     - include: tasks/software.yml
  25.       tags: [whitebox, packages]
  26.     - include: tasks/security.yml
  27.       tags: [whitebox, security]
  28.     - include: tasks/users.yml
  29.       tags: [whitebox, users]
  30.  
  31.   handlers:
  32.     - include: handlers/site.yml  
  33.  
  34.   # install all the goodness
  35.   roles:
  36.     - { role: qualitybox, tags: ["qualitybox", "mediawiki"] }
  37.     - { role: install_git, tags: ["qualitybox", "mediawiki"] }
  38.     - { role: deploy_mw_host, tags: ["qualitybox", "mediawiki"] }
  39.  
  40. # Add more plays to the playbook
  41. - include: install_mediawiki.yml
  42. - include: install_extensions.yml
  43. - include: install_skins.yml
  44. # finally create the wiki
  45. #  - include: create_new_wiki.yml
  46. #  - vars: WIKI_NAME=mywiki
  47.  
  48.  
  49. ######### Which eventually includes roles/install_mediawiki/tasks/main.yml ############
  50. #########                           containing task                        ############
  51.  
  52. - name: grant access to empty wiki to wiki user (db host != wiki host)
  53.   mysql_user:
  54.    name={{ MYSQL_WIKI_USER }}
  55.     password={{ MYSQL_WIKI_PASSWORD }}
  56.     priv="{{ EMPTY_WIKI_NAME }}.*:SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,DROP,CREATE TEMPORARY TABLES"
  57.     append_privs=true
  58.     host={{ wiki_hostname }}
  59.     login_user=root
  60.   when: inventory_hostname != wiki_hostname
  61.  
  62.  
  63. ####### Gives this output  ###########################################################
  64.  
  65. TASK [install_mediawiki : grant access to empty wiki to wiki user (db host != wiki host)] ***
  66. task path: /home/greg/src/ansible-digitalocean/roles/install_mediawiki/tasks/main.yml:36
  67. fatal: [wiki.example.com]: FAILED! => {
  68.     "failed": true,
  69.     "msg": "The conditional check 'inventory_hostname != wiki_hostname' failed. The error was: error while evaluating conditional (inventory_hostname != wiki_hostname): 'wiki_hostname' is undefined\n\nThe error appears to have been in '/home/greg/src/ansible-digitalocean/roles/install_mediawiki/tasks/main.yml': line 36, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# These steps assume that QualityBox role has already been run to create .my.cnf\n- name: grant access to empty wiki to wiki user (db host != wiki host)\n  ^ here\n"
  70. }
  71.  
  72. NO MORE HOSTS LEFT *************************************************************
  73.         to retry, use: --limit @provision.retry
  74.  
  75. PLAY RECAP *********************************************************************
  76. wiki.example.com           : ok=9    changed=3    unreachable=0    failed=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement