Undefined variable when trying to pass username and password through Ansible Git Module











up vote
0
down vote

favorite












I have a follow up question to the thread in here:
How do I pass username and password while using Ansible Git module?



I am trying to achieve a similar task where I am passing a username and password to GitHub through Ansible. Here is what I am using for my playbook:



- name: ANSIBLE - Shop Installation
hosts: host_list
vars_prompt:
- name: "githubuser"
prompt: "Enter your github username"
private: no
- name: "githubpassword"
prompt: "Enter your github password"
private: yes

- hosts: host_list
tasks:
- name: Get the latest version through Git
git:
repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
dest: /tmp


After running through this, I get the following error message:



fatal: : FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'githubuser' is undefinednnThe error appears to have been in 'playbook.yml'



Any ideas where I may have gone wrong here?



I am running Ansible 2.7.1










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a follow up question to the thread in here:
    How do I pass username and password while using Ansible Git module?



    I am trying to achieve a similar task where I am passing a username and password to GitHub through Ansible. Here is what I am using for my playbook:



    - name: ANSIBLE - Shop Installation
    hosts: host_list
    vars_prompt:
    - name: "githubuser"
    prompt: "Enter your github username"
    private: no
    - name: "githubpassword"
    prompt: "Enter your github password"
    private: yes

    - hosts: host_list
    tasks:
    - name: Get the latest version through Git
    git:
    repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
    dest: /tmp


    After running through this, I get the following error message:



    fatal: : FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'githubuser' is undefinednnThe error appears to have been in 'playbook.yml'



    Any ideas where I may have gone wrong here?



    I am running Ansible 2.7.1










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a follow up question to the thread in here:
      How do I pass username and password while using Ansible Git module?



      I am trying to achieve a similar task where I am passing a username and password to GitHub through Ansible. Here is what I am using for my playbook:



      - name: ANSIBLE - Shop Installation
      hosts: host_list
      vars_prompt:
      - name: "githubuser"
      prompt: "Enter your github username"
      private: no
      - name: "githubpassword"
      prompt: "Enter your github password"
      private: yes

      - hosts: host_list
      tasks:
      - name: Get the latest version through Git
      git:
      repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
      dest: /tmp


      After running through this, I get the following error message:



      fatal: : FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'githubuser' is undefinednnThe error appears to have been in 'playbook.yml'



      Any ideas where I may have gone wrong here?



      I am running Ansible 2.7.1










      share|improve this question













      I have a follow up question to the thread in here:
      How do I pass username and password while using Ansible Git module?



      I am trying to achieve a similar task where I am passing a username and password to GitHub through Ansible. Here is what I am using for my playbook:



      - name: ANSIBLE - Shop Installation
      hosts: host_list
      vars_prompt:
      - name: "githubuser"
      prompt: "Enter your github username"
      private: no
      - name: "githubpassword"
      prompt: "Enter your github password"
      private: yes

      - hosts: host_list
      tasks:
      - name: Get the latest version through Git
      git:
      repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
      dest: /tmp


      After running through this, I get the following error message:



      fatal: : FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'githubuser' is undefinednnThe error appears to have been in 'playbook.yml'



      Any ideas where I may have gone wrong here?



      I am running Ansible 2.7.1







      ansible






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 1:16









      TheOrangeRemix

      41238




      41238
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          I think the structure of your playbook is wrong. Try this:



          ---
          - hosts: host_list
          vars_prompt:
          - name: "githubuser"
          prompt: "Enter your github username"
          private: no
          - name: "githubpassword"
          prompt: "Enter your github password"
          private: yes

          tasks:
          - name: Get the latest version through Git
          git:
          repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
          dest: /tmp





          share|improve this answer





















          • Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
            – TheOrangeRemix
            Nov 12 at 16:26


















          up vote
          0
          down vote













          Scope of vars_prompt is a playbook.



          Variable githubuser is defined in the first play. Second play knows nothing about it.




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?




          An option would be to configure fact_caching. For example with Redis



          [defaults]
          fact_caching=redis


          In the first play store the variables with set_fact cacheable: yes



          In the second play fetch data from Redis






          share|improve this answer























          • Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
            – TheOrangeRemix
            Nov 11 at 17:42











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235196%2fundefined-variable-when-trying-to-pass-username-and-password-through-ansible-git%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          I think the structure of your playbook is wrong. Try this:



          ---
          - hosts: host_list
          vars_prompt:
          - name: "githubuser"
          prompt: "Enter your github username"
          private: no
          - name: "githubpassword"
          prompt: "Enter your github password"
          private: yes

          tasks:
          - name: Get the latest version through Git
          git:
          repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
          dest: /tmp





          share|improve this answer





















          • Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
            – TheOrangeRemix
            Nov 12 at 16:26















          up vote
          1
          down vote



          accepted










          I think the structure of your playbook is wrong. Try this:



          ---
          - hosts: host_list
          vars_prompt:
          - name: "githubuser"
          prompt: "Enter your github username"
          private: no
          - name: "githubpassword"
          prompt: "Enter your github password"
          private: yes

          tasks:
          - name: Get the latest version through Git
          git:
          repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
          dest: /tmp





          share|improve this answer





















          • Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
            – TheOrangeRemix
            Nov 12 at 16:26













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          I think the structure of your playbook is wrong. Try this:



          ---
          - hosts: host_list
          vars_prompt:
          - name: "githubuser"
          prompt: "Enter your github username"
          private: no
          - name: "githubpassword"
          prompt: "Enter your github password"
          private: yes

          tasks:
          - name: Get the latest version through Git
          git:
          repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
          dest: /tmp





          share|improve this answer












          I think the structure of your playbook is wrong. Try this:



          ---
          - hosts: host_list
          vars_prompt:
          - name: "githubuser"
          prompt: "Enter your github username"
          private: no
          - name: "githubpassword"
          prompt: "Enter your github password"
          private: yes

          tasks:
          - name: Get the latest version through Git
          git:
          repo: 'https://{{ githubuser }}:{{ githubpassword }}@github.com/foo/bar.git'
          dest: /tmp






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 6:54









          JGK

          876311




          876311












          • Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
            – TheOrangeRemix
            Nov 12 at 16:26


















          • Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
            – TheOrangeRemix
            Nov 12 at 16:26
















          Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
          – TheOrangeRemix
          Nov 12 at 16:26




          Yup, you're right; my structure was incorrect. Your suggestion fixed it. Thanks!
          – TheOrangeRemix
          Nov 12 at 16:26












          up vote
          0
          down vote













          Scope of vars_prompt is a playbook.



          Variable githubuser is defined in the first play. Second play knows nothing about it.




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?




          An option would be to configure fact_caching. For example with Redis



          [defaults]
          fact_caching=redis


          In the first play store the variables with set_fact cacheable: yes



          In the second play fetch data from Redis






          share|improve this answer























          • Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
            – TheOrangeRemix
            Nov 11 at 17:42















          up vote
          0
          down vote













          Scope of vars_prompt is a playbook.



          Variable githubuser is defined in the first play. Second play knows nothing about it.




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?




          An option would be to configure fact_caching. For example with Redis



          [defaults]
          fact_caching=redis


          In the first play store the variables with set_fact cacheable: yes



          In the second play fetch data from Redis






          share|improve this answer























          • Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
            – TheOrangeRemix
            Nov 11 at 17:42













          up vote
          0
          down vote










          up vote
          0
          down vote









          Scope of vars_prompt is a playbook.



          Variable githubuser is defined in the first play. Second play knows nothing about it.




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?




          An option would be to configure fact_caching. For example with Redis



          [defaults]
          fact_caching=redis


          In the first play store the variables with set_fact cacheable: yes



          In the second play fetch data from Redis






          share|improve this answer














          Scope of vars_prompt is a playbook.



          Variable githubuser is defined in the first play. Second play knows nothing about it.




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?




          An option would be to configure fact_caching. For example with Redis



          [defaults]
          fact_caching=redis


          In the first play store the variables with set_fact cacheable: yes



          In the second play fetch data from Redis







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 11 at 21:33

























          answered Nov 10 at 8:35









          Vladimir Botka

          72938




          72938












          • Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
            – TheOrangeRemix
            Nov 11 at 17:42


















          • Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
            – TheOrangeRemix
            Nov 11 at 17:42
















          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
          – TheOrangeRemix
          Nov 11 at 17:42




          Would I have to pass the variable value from the first play to the second? What's the correct way of doing that in this context?
          – TheOrangeRemix
          Nov 11 at 17:42


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235196%2fundefined-variable-when-trying-to-pass-username-and-password-through-ansible-git%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)