Uploaded image for project: 'IGB'
  1. IGB
  2. IGBF-2335

Investigate error in deployEC2 role - "skipping: no hosts matched"

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Please investigate and hopefully fix the cause of this error encountered upon running ansible playbooks for appstore:

      quoting error

      Ansible ec2-user $ ansible-playbook main.yml
      [WARNING]: No inventory was parsed, only implicit localhost is available
      [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
      not match 'all'
      [WARNING]: Could not match supplied host pattern, ignoring: local

      PLAY [local] ***********************************************************************************************
      skipping: no hosts matched
      [WARNING]: Could not match supplied host pattern, ignoring: ec2_server

      PLAY [ec2_server] ******************************************************************************************
      skipping: no hosts matched

      PLAY RECAP **************************************************************************************

        Attachments

          Activity

          Hide
          ann.loraine Ann Loraine added a comment -

          ansible --version returns:

          ansible 2.9.6
          config file = /home/ec2-user/appstore-playbooks/Ansible/ansible.cfg
          configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
          ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
          executable location = /usr/local/bin/ansible
          python version = 3.7.6 (default, Feb 26 2020, 20:54:15) [GCC 7.3.1 20180712 (Red Hat 7.3.1-6)]

          cc: Chester Dias

          Show
          ann.loraine Ann Loraine added a comment - ansible --version returns: ansible 2.9.6 config file = /home/ec2-user/appstore-playbooks/Ansible/ansible.cfg configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.7/site-packages/ansible executable location = /usr/local/bin/ansible python version = 3.7.6 (default, Feb 26 2020, 20:54:15) [GCC 7.3.1 20180712 (Red Hat 7.3.1-6)] cc: Chester Dias
          Hide
          ann.loraine Ann Loraine added a comment -

          Use private IP addresses to communicate between ansible control node and targets.
          We can gather facts on the localhost (control node) to get its private IP address. (Public is not available.)
          Then we can add the target node's IP address to the in-memory inventory during playbook execution.
          We use the key pair private key to communicate with and configure the target node.
          In addition, we add the private IP address of the control node to a security group attached to the target node.

          Show
          ann.loraine Ann Loraine added a comment - Use private IP addresses to communicate between ansible control node and targets. We can gather facts on the localhost (control node) to get its private IP address. (Public is not available.) Then we can add the target node's IP address to the in-memory inventory during playbook execution. We use the key pair private key to communicate with and configure the target node. In addition, we add the private IP address of the control node to a security group attached to the target node.
          Hide
          ann.loraine Ann Loraine added a comment -

          Solutions (following up on previous comment):

          • Add the newly created or previously created AppStore EC2 to in-memory inventory using its private IP address - for example, add it to group "appstores"
          • Refer to its group ("appstores") in the "master" playbook (e.g., main.yml) for subsequent plays and roles

          Other thoughts:

          • Rather than use one externally created key pair for provisioning all appstore EC2s, let's instead have the control node use ec2_key to create a keypair for the appstore.
          Show
          ann.loraine Ann Loraine added a comment - Solutions (following up on previous comment): Add the newly created or previously created AppStore EC2 to in-memory inventory using its private IP address - for example, add it to group "appstores" Refer to its group ("appstores") in the "master" playbook (e.g., main.yml) for subsequent plays and roles Other thoughts: Rather than use one externally created key pair for provisioning all appstore EC2s, let's instead have the control node use ec2_key to create a keypair for the appstore.
          Hide
          ann.loraine Ann Loraine added a comment - - edited

          Using existing code as a starting point, adapted some of the existing plays into new roles.

          Create next draft of appstore EC2 playbooks - see commit:

          Show
          ann.loraine Ann Loraine added a comment - - edited Using existing code as a starting point, adapted some of the existing plays into new roles. Create next draft of appstore EC2 playbooks - see commit: https://bitbucket.org/lorainelab/appstore-playbooks/commits/e8a6e7ea6d1504ba1f0774c4493318516c4aacd3
          Hide
          ann.loraine Ann Loraine added a comment -

          Using the existing playbooks as a guide and first draft, I developed a next draft of the appstore playbooks.

          For the next steps, could you take a look?

          To run the new roles:

          • Set up and configure a control node
          • Copy group_vars/example_secrets.yml to group_vars/secrets.yml on your control node
          • Edit "AWS" variables only (ignore "rds" variables for now). These credentials should be for your personal account as they will be used to do things such as create a key_pair, create an EC2, create and modify security groups.
          • Encrypt secrets.yml using ansible-vault as per usual
          • Edit variable in group_vars/common.yml - change variables vpc_subnet_id and rds_instance_name to match your account.
          • Run the playbook setup.yml.

          Dependencies:

          • Your account needs to have an RDS host already created before you run setup.yml playbook.
          • Indicate the name of the host (e.g., dev-appstore-n or dev) in group_vars/common.yml.
          • You also need to have a control node already set up. Please see ControlNode folder in the git repository.

          Notes:

          • Building from the existing playbooks, I included creation of a security group that will be attached to the Dev AppStore being created. This ends the need to create such a thing in advance before running the playbook.
          • I included steps to create a keypair specific to the Dev AppStore being created and provisioned.
          • I had some problems with the prompt configuration step, which needs to edit files in the root and ansible_ssh_user accounts. I'm not sure why but this sometimes failed. It might have something to do with VM (EC2) lifecycle.
          Show
          ann.loraine Ann Loraine added a comment - Using the existing playbooks as a guide and first draft, I developed a next draft of the appstore playbooks. For the next steps, could you take a look? To run the new roles: Set up and configure a control node Copy group_vars/example_secrets.yml to group_vars/secrets.yml on your control node Edit "AWS" variables only (ignore "rds" variables for now). These credentials should be for your personal account as they will be used to do things such as create a key_pair, create an EC2, create and modify security groups. Encrypt secrets.yml using ansible-vault as per usual Edit variable in group_vars/common.yml - change variables vpc_subnet_id and rds_instance_name to match your account. Run the playbook setup.yml. Dependencies: Your account needs to have an RDS host already created before you run setup.yml playbook. Indicate the name of the host (e.g., dev-appstore-n or dev) in group_vars/common.yml. You also need to have a control node already set up. Please see ControlNode folder in the git repository. Notes: Building from the existing playbooks, I included creation of a security group that will be attached to the Dev AppStore being created. This ends the need to create such a thing in advance before running the playbook. I included steps to create a keypair specific to the Dev AppStore being created and provisioned. I had some problems with the prompt configuration step, which needs to edit files in the root and ansible_ssh_user accounts. I'm not sure why but this sometimes failed. It might have something to do with VM (EC2) lifecycle.
          Hide
          cdias1 Chester Dias (Inactive) added a comment -

          The issue was more ansible oriented. whenever we don't mention the server names in the hosts inventory, by default ansible should have picked localhost to start with, but it seemed to ignore that in this version of ansible(looks like a new addition to ansible). I have found a solution by changing the hosts from local to localhost and removing the connection type. I will confirm this change and commit it in some time.

          Show
          cdias1 Chester Dias (Inactive) added a comment - The issue was more ansible oriented. whenever we don't mention the server names in the hosts inventory, by default ansible should have picked localhost to start with, but it seemed to ignore that in this version of ansible(looks like a new addition to ansible). I have found a solution by changing the hosts from local to localhost and removing the connection type. I will confirm this change and commit it in some time.
          Hide
          cdias1 Chester Dias (Inactive) added a comment -

          I have commented on the PR
          The initial draft playbooks also needs a small change in main.yml

          • hosts: localhost
            and removal of connection :local
            I found that this change gives some speed in ansible execution
          Show
          cdias1 Chester Dias (Inactive) added a comment - I have commented on the PR The initial draft playbooks also needs a small change in main.yml hosts: localhost and removal of connection :local I found that this change gives some speed in ansible execution
          Hide
          ann.loraine Ann Loraine added a comment -

          That solves it! Marking this issue as done.

          Show
          ann.loraine Ann Loraine added a comment - That solves it! Marking this issue as done.

            People

            • Assignee:
              cdias1 Chester Dias (Inactive)
              Reporter:
              ann.loraine Ann Loraine
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: