Bookmark this page

Guided Exercise: Configuring System Settings Using Surveys

Create a survey to provide values for variables that are used by the Ansible Playbook run by the job template, such as the device hostname and DNS settings.

Outcomes

  • Create an automation controller job template.

  • Add a survey to an existing job template.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise, and to ensure that all required resources are available.

This command also creates two Git repositories and the following automation controller resources:

  • The Cisco IOS XE Auth machine credential

  • The Inventories project

  • The Common inventory

  • The Surveys project

  • The Check Cisco DNS job template

[student@workstation ~]$ lab start manage-surveys

Instructions

  1. Check the existing hostname and DNS settings for the Cisco IOS managed nodes.

    1. Navigate to https://controller.lab.example.com and log in as admin using redhat as the password.

    2. Click the main menu icon at the top left of the page. Navigate to ResourcesTemplates and click the Launch Template icon for the Check Cisco DNS job template.

      The job displays the following output:

      ...output omitted...
      TASK [Display hostname] *********************************************************
      ok: [iosxe1.lab.example.com] => {
          "ansible_facts['net_hostname']": "iosxe1.lab.example.com"
      }
      ok: [iosxe2.lab.example.com] => {
          "ansible_facts['net_hostname']": "iosxe2.lab.example.com"
      }
      
      TASK [Display DNS lookup status] ************************************************
      ok: [iosxe1.lab.example.com] => {
          "lookup_enabled_msg | trim": "DNS lookup enabled"
      }
      ok: [iosxe2.lab.example.com] => {
          "lookup_enabled_msg | trim": "DNS lookup enabled"
      }
      
      TASK [Display DNS name servers] *************************************************
      ok: [iosxe2.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip name-server .*$', multiline=true) | first": "ip name-server 172.25.250.220"
      }
      ok: [iosxe1.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip name-server .*$', multiline=true) | first": "ip name-server 172.25.250.220"
      }
      
      TASK [Display DNS domain search] ************************************************
      ok: [iosxe1.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip domain list .*$', multiline=true)": [
              "ip domain list lab.example.com"
          ]
      }
      ok: [iosxe2.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip domain list .*$', multiline=true)": [
              "ip domain list lab.example.com"
          ]
      }
      ...output omitted...
  2. Create the Configure Cisco DNS job template.

    1. Navigate to ResourcesTemplates and click AddAdd job template. Create the job template with the following settings, and then click Save:

      FieldValue
      Name Configure Cisco DNS
      Inventory Common
      Project Surveys
      Playbook cisco_configuration.yml
      Credentials Cisco IOS XE Auth
  3. Add four survey questions to the Configure Cisco DNS job template.

    1. Navigate to ResourcesTemplates and then click the Configure Cisco DNS link. Click the Survey tab.

    2. Use the following tables for the survey questions. For each survey question, click Add to begin creating the question and then click Save when you finish.

      Table 4.2. Survey Question 1

      FieldValue
      Question Default domain name
      Description This domain is used to set the hostname of the node.
      Answer variable name global_domain_name
      Answer type Text
      Required (selected)
      Minimum length 1
      Maximum length 251
      Default Answer lab.example.com

      Important

      This exercise does not change DNS records. When you launch the Configure Cisco DNS job template, entering a value other than lab.example.com for the global_domain_name variable does set a new hostname, but you cannot reach the managed node by the new hostname.

      Table 4.3. Survey Question 2

      FieldValue
      Question Enable DNS lookups?
      Answer variable name ios_dns_lookup_enabled
      Answer Type Multiple Choice (single select)
      Required (selected)
      Multiple Choice Options true (selected as default)
      false (not selected as default)

      Table 4.4. Survey Question 3

      FieldValue
      Question Select DNS servers
      Answer variable name ios_name_servers
      Answer Type Multiple Choice (multiple select)
      Required (selected)
      Multiple Choice Options 172.25.250.220 (selected as default)
      1.1.1.1 (not selected as default)
      8.8.8.8 (not selected as default)

      Table 4.5. Survey Question 4

      FieldValue
      Question Select domain search paths
      Answer variable name ios_domain_search
      Answer Type Multiple Choice (multiple select)
      Required (selected)
      Multiple Choice Options lab.example.com (selected as default)
      example.com (not selected as default)
      redhat.com (not selected as default)
      ansible.com (not selected as default)

  4. Enable the survey for the Configure Cisco DNS job template.

    1. Navigate to ResourcesTemplates and click the Configure Cisco DNS link. Click the Survey tab.

    2. Click Survey Disabled and verify that the label changes to Survey Enabled.

      Figure 4.5: Enabled survey with questions
  5. Launch the Configure Cisco DNS job template.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Configure Cisco DNS job template. The automation controller web UI opens a dialog box with the job template survey.

    2. Select 1.1.1.1 as an additional entry from the Select DNS servers list.

    3. Select example.com as an additional entry from the Select domain search paths list.

    4. Click Next to preview the settings for the job template.

    5. Click Launch to launch the job template and use the variables defined by the survey. The Configure Cisco DNS job displays a status of Successful.

  6. Verify the changes made by the Configure Cisco DNS job template.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Check Cisco DNS job template.

      The job output displays the updated DNS name servers and domain search entries:

      ...output omitted...
      TASK [Display DNS name servers] *************************************************
      ok: [iosxe1.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip name-server .*$', multiline=true) | first": "ip name-server 172.25.250.220 1.1.1.1"
      }
      ok: [iosxe2.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip name-server .*$', multiline=true) | first": "ip name-server 172.25.250.220 1.1.1.1"
      }
      
      TASK [Display DNS domain search] ************************************************
      ok: [iosxe2.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip domain list .*$', multiline=true)": [
              "ip domain list lab.example.com",
              "ip domain list example.com"
          ]
      }
      ok: [iosxe1.lab.example.com] => {
          "ansible_facts['net_config'] | regex_findall('^ip domain list .*$', multiline=true)": [
              "ip domain list lab.example.com",
              "ip domain list example.com"
          ]
      }
      ...output omitted...

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish manage-surveys

Revision: do457-2.3-7cfa22a