当前位置:网站首页>Goldfish rhca memoirs: do447 managing projects and carrying out operations -- creating job templates and starting jobs

Goldfish rhca memoirs: do447 managing projects and carrying out operations -- creating job templates and starting jobs

2022-06-27 21:14:00 Hua Weiyun

Personal profile : Hello everyone , I am a Brother goldfish ,CSDN New star creator in operation and maintenance field , Hua Wei Yun · Cloud sharing experts
Personal qualifications :CCNA、HCNP、CSNA( Network Analyst ), Soft test primary 、 Intermediate network engineer 、RHCSA、RHCE、RHCA、RHCI、ITIL
Maxim : Hard work doesn't necessarily succeed , But if you want to succeed, you must work hard

Stand by me : I like it 、 Can collect ️、 Leave message


Official website :

https://docs.ansible.com/ansible-tower/3.8.1/html_zh/userguide/job_templates.html


9.2.1 Job template 、 Items and lists

stay Red Hat Ansible Tower in , A job template is a template used to start a job that runs a script . The job template will come from the script and host list of the project 、 Credentials for authentication and startup Ansible The job is associated with other parameters used when running the script . Whether a user can start a job or create a job with a specific project and inventory Job template , It depends on the roles you assign them . When granted Use Role time , Users can use job templates to associate items with lists .

The job template defines the execution Ansible Parameters of the job .Ansible The job executes a script on a set of managed hosts . therefore , The job template must define what projects provide scripts , What list contains a list of managed hosts .

Besides , The job template must also define machine credentials , This credential will be used to authenticate the managed host . Like items and lists , The user must have credentials assigned to the machine Use role , To associate it to the job template .

Once defined , The job template allows the repeated execution of jobs , Therefore, it is an ideal choice for routine execution of tasks . because Project、Inventory and Machine Credential Parameters are part of the job template definition , So the job will run the same way every time .


9.2.2 Create job template

And others Ansible Tower Different resources , Job templates do not belong directly to an organization , It is used by projects belonging to an organization . The relationship between the job template and the organization is determined by the project it uses . therefore , When creating a job template , You don't need to have... In the organization Admin role . contrary , You only need to have the project assigned to the job template Use role .

Because the job template must use Inventory、Project and Machine Credential To define , So only if the user has Use Role time , They can create job templates , These three Ansible Tower Each resource has one or more . The following steps detail how to create a job template , Used to run a script on a set of managed hosts , Focus on mandatory parameters ( Optional parameters will be discussed later ):

  1. As has been assigned Inventory、Project and Machine Credential Resources Use User login for role Ansible Tower web Interface

  2. Click... In the left quick navigation bar “ Templates ”, Enter the template management interface .

  3. single click + Button , And then choose Job Template.

  4. stay name Enter a name for the job template in the field .

  5. choice Run As JOB TYPE.

  6. Specifies the managed host on which the job will be executed

​ 1. Click the magnifying glass icon in the item bar .

​ 2. Select the desired list , And then click Select.

  1. Specify the project that contains the script that the task will execute .

​ 1. single click PROJECT Field magnifying glass icon

​ 2. Select the desired item , And then click Select.

  1. Specifies the script that the job will execute .

​ 1. single click PLAYBOOK Drop down menu of field . Lists the... Selected in the previous field “ project ” All scripts included in .

​ 2. Choose the script you want .

  1. Specify the credentials required to authenticate the managed host .

​ 1. single click CREDENTIAL Field magnifying glass icon

​ 2. Select the required credentials , And then click Select

  1. From the drop-down menu verbose Field to select the desired settings . This determines the level of detail generated in the output of the job run .
  2. single click SAVE To complete the new Job Template The creation of .
     Insert picture description here

9.2.3 Modify job execution

When the template starts , You can use other settings to adjust Ansible Tower How to run a script :

DESCRIPTION

This field is used to store an optional description of the job template .


FORKS

Use this field to specify fork Set up , This setting controls the number of parallel processes allowed during script execution . This is equivalent to ansible-playbook Ordered -f or --forks Options . If the value is 0, Then use Ansible Default settings in the configuration file .


LIMIT

The list of hosts in the managed template can be used to restrict the use of this list . Filtering is done by providing a host mode as a value for this field . This is equivalent to ansible-playbook Ordered -l or -limit Options .


JOB TAGS

This field accepts a comma separated list of tags that exist in the script . Tags are used to identify different parts of the script . By specifying the tag list in this field , You can optionally execute only some parts of the script . This is equivalent to ansible-playbook Ordered -t or tags Options .


SKIP TAGS

This field accepts a comma separated list of tags that exist in the script . By specifying a tag list in this field , You can optionally skip parts of the script during execution . This is equivalent to ansible-playbook Ordered –skip-tags Options .


LABELS

Tags can be attached to “ Job template ” The name on , To help you with “ Job template ” Group or filter .


Enable Privilege Escalation

When this check box is enabled , The script will be executed with upgrade privileges . This is equivalent to ansible-playbook Ordered –become Options .


Allow Provisioning Callbacks

When enabled , This check box will result in Ansible Tower Create a supply callback on URL, The host can use this URL Request to use Job Template Make configuration updates .


Enable Concurrent Jobs

When enabled , This check box allows this job template to be executed multiple times at the same time .


Use Fact Cache

When enabled , This check box will result in the fact that the cache is used , And store the newly discovered facts in Ansible Tower In the fact cache . Fact caching will be discussed in more detail later in this course .


EXTRA VARIABLES

And ansible-playbook Ordered -e or –extra-vars The options are the same , This field can be used to pass additional command-line variables to the job execution playbook. These additional variables are defined as using YAML or JSON Key / It's worth it .


9.2.4 Operation parameter prompt

When using ansible-playbook When the command executes the script from the command line , Administrators can modify the execution of scripts by using command-line options .Ansible Tower Some parameters in the job template are allowed to prompt the user to enter when the job is executed , This flexibility is achieved . This startup prompt option applies to :

• JOB TYPE

• INVENTORY

• CREDENTIAL

• LIMIT

• VERBOSITY

• JOB TAGS

• SKIP TAGS

• EXTRA VARIABLES

The flexibility of changing job parameters during job execution encourages the reuse of scripts . for example , Instead of creating multiple job templates to run the same script on different managed hosts , Better for Inventory Field enable Prompt on launch A single job template with options is sufficient . When the job starts , The user can select a job to execute Inventory To execute the script . When prompted , Users can only from inventory Choose to assign to them Use The object of the character .
 Insert picture description here


9.2.5 Role of job template

There are three roles used to control users' access to job templates .

Admin

Admin Roles provide users with the ability to delete job templates or edit their properties ( Include its associated permissions ) The ability of . This role is also granted to the job template Execute and Read The permissions associated with the role .


Execute

“ perform ” The role is granted to the user to use “ Job template ” Permission to execute the job . It also grants Users Permission to schedule jobs using job templates . This role is also granted to “ Job template reading ” The permissions associated with the role


important : The job template takes advantage of other Ansible Tower resources , Such as project 、 List and credentials . For users who use job templates to execute jobs , They just need to assign... On the job template execute role , And there's no need to Use Roles are assigned to any of these associated Ansible Tower resources .


Read

“Read” The role gives the user read-only permission to view the properties of the job template . It also grants access to view other information related to the job template , For example, the list of jobs executed using the job template , And its related permissions and notifications .


9.2.6 Manage job template access

When you first create a job template , Only the user who created the job template or the organization in which the project was created has Admin or Auditor Only users of the role can access the job template . if necessary , Additional access must be specially configured

Assign the job template roles discussed earlier to users or teams , Specifies who has the permission of the job template . These permissions cannot be assigned when creating a job template . They are managed after creating job templates by editing job templates .

The role is through Job Template Editor screen PERMISSIONS Partially allocated . After the job template is created , Please follow the steps below to grant permission .

  1. The organization associated with the job template has “Admin” The user of the role or the user who created the job template logs in .

  2. Click... In the left quick navigation bar “TEMPLATES”, Displays a list of templates .

  3. Click the pencil icon of the job template to edit , Enter the job template editor screen .

  4. stay Job Template Editor screen , single click PERMISSIONS Button to enter the permission editor .

  5. single click + Button to add permissions .

  6. In the user and team selection screens , single click USERS or TEAMS, Then select the user or team you want to grant permissions to .

  7. single click KEY Show Job Template List of roles and their definitions .

  8. single click SELECT ROLES The drop-down menu , Choose what you want for each user or team Job Template role .

  9. single click SAVE To complete the change of permissions
     Insert picture description here


9.2.7 Start work

Once the job template is created , You can use it to start a job using the following procedure .

1. Use “ Task template ” There is “ Executive role ” User login

2. Click... In the left quick navigation bar Templates View the list of templates .

3. Find the desired job template in the template list , And click ACTIONS The rocket icon under the column to start the job .

4 If anything Job Template Parameters are enabled Prompt on launch Options , Then you will be prompted to enter before the job is executed . Enter the required input for each parameter prompted , And click LAUNCH To start the job .
 Insert picture description here


9.2.8 Evaluate the results of the assignment

When an assignment starts from Ansible Tower web After the job template in the interface is started , The user will automatically redirect to the details page of the job . Users can also click... In the quick navigation bar on the left job To browse the list of executed jobs , Then click the job link of interest , To navigate to the same page .

The job details page is divided into two panes .DETAILS The pane displays the details of the job parameters , The job output pane displays the output of the script executed by the job .

Although the output and use in the job output pane ansible-playbook The command executes the script on the command line and produces output similar to , But it also provides several additional features . At the top of the job output pane is a summary , Details the number of scripts and tasks performed 、 The number of hosts executing the job and the time required for job execution . Besides , Controls are also provided to maximize the pane to full screen size , And the output for downloading job execution .

On the left side of the output section , have access to + and - Control to expand or collapse the output of each task in the script . On the right side of the output section are controls for scrolling the output and jumping to the beginning and end of the output
 Insert picture description here


9.2.9 Textbook exercises

[[email protected] ~]$ lab provision-job start

1. With admin Account number and redhat Password to login Ansible Tower web.


2. Create a file called DEV webservers setup New job template .

 Insert picture description here
 Insert picture description here


3. stay DEV webservers setup Set up Developers The team Admin role .

3.1 single click PERMISSIONS Button to manage the permissions of the job template .

3.2 Click on the right + Button to add permissions .

3.3 single click TEAMS A list of available teams can be displayed .

3.4 In the first part , Check the box next to the developer team . This will cause the team to appear in the second part below the first part

3.5 In the second section below . Select from the drop-down menu Admin role .

3.6 single click SAVE Assign roles . This will redirect you to the permission list or job template ,DEV webservers setup, It now shows that all members of the development team have been assigned the administrator role on the job template .
 Insert picture description here


4. As a member of the developer team , Use job template DEV webservers setup Start a Job.

4.1 Click on the “ sign out ” Icon , Exit with daniel Use a password for your identity redhat123 Log back in .

4.2 In the left navigation bar , single click “ Templates ” Quick navigation links .

4.3 In connection with the job template ,DEV webservers setup On the same line , Click the rocket icon on the right to start the job . This will redirect you to the detailed status page of the running job

4.4 Observe the real-time output of the running job for one minute

4.5 Check DETAILS In the part Job Of STATUS Whether or not shown Successful.
 Insert picture description here


5. verification web The server has started and is running on the server .

[[email protected] ~]$ curl serveraThis is a test message RedHat 8.0 <br>Current Host: servera <br>Server list: <br>serverb.lab.example.com <br>servera.lab.example.com <br>[[email protected] ~]$ curl serverbThis is a test message RedHat 8.0 <br>Current Host: serverb <br>Server list: <br>serverb.lab.example.com <br>servera.lab.example.com <br>

6. Clear pull code .

[[email protected] ~]$ cd ~/git-repos[[email protected] git-repo]$ git clone  http://[email protected]:8081/git/my_webservers_DEV.git[[email protected] git-repo]$ cd my_webservers_DEV[[email protected] my_webservers_DEV]$ git pullAlready up to date.

7. Simulation code update .

[[email protected] my_webservers_DEV]$ cp -R -v ~/DO447/labs/provision-job/* .'/home/student/DO447/labs/provision-job/ansible-vsftpd.yml' -> './ansible-vsftpd.yml''/home/student/DO447/labs/provision-job/ftpclient.yml' -> './ftpclient.yml''/home/student/DO447/labs/provision-job/site.yml' -> './site.yml''/home/student/DO447/labs/provision-job/templates' -> './templates''/home/student/DO447/labs/provision-job/templates/vsftpd.conf.j2' -> './templates/vsftpd.conf.j2''/home/student/DO447/labs/provision-job/vars' -> './vars''/home/student/DO447/labs/provision-job/vars/defaults-template.yml' -> './vars/defaults-template.yml''/home/student/DO447/labs/provision-job/vars/vars.yml' -> './vars/vars.yml'[[email protected] my_webservers_DEV]$ git add --all[[email protected] my_webservers_DEV]$ git commit -m "Adding playbooks"[[email protected] my_webservers_DEV]$ git push

8. Trigger My webservers DEV Project SCM to update .

8.1 go back to Ansible Tower Web interface . You should still be daniel The user login

8.2 In the left navigation bar , single click project Quick navigation links .

8.3 stay My webservers DEV In the item line , Click the double arrow icon .

8.4 Watch the update and wait a few seconds . In the project list , my webservers DEV There is a status icon on the left side of the project . This icon starts in white , Red when failed , With exclamation marks (!), Green when successful

8.5 Click the logout icon to exit Ansible Tower Of web Interface .
 Insert picture description here


9. With admin Account number and redhat Password to login Ansible Tower web.


10. Create a new job template , be known as DEV ftpservers setup

 Insert picture description here

Be careful :My webservers DEV The project provides additional scripts for you to choose from , Because you've put extra Ansible The script and template are pushed to the same... As the remote source code of the project Git Repository .
 Insert picture description here


11. In the job template DEV ftpservers setup Give to Developers The team Admin role .

 Insert picture description here


12. As a member of the development team , Use job template DEV ftpservers setup Start the job .

12.1 Click on the “ Cancellation ” Icon , Log out and start with daniel Login as , The password for redhat123

12.2 In the left navigation bar , single click Templates Quick navigation links

12.3 stay Job Template DEV ftpservers setup On the same line , Click the rocket icon on the right to launch Job. This will redirect you to the detailed status page of the running job .

12.4 Observe the real-time output of the running job for one minute .

12.5 Check DETAILS In the part Job Of STATUS Whether or not shown Successful.
 Insert picture description here


13. confirm FTP The server has started and is running on the server .

[[email protected] ~]$ nc servera 21220 (vsFTPd 3.0.3)^C[[email protected] ~]$ nc serverb 21220 (vsFTPd 3.0.3)^C

14. Click the logout icon to exit Ansible Tower Of web Interface .


9.3 Chapter experiment

This experiment does not take notes , Practice by yourself .

[[email protected] ~]$ lab provision-review start

1. Create the project as required

ssh://git.lab.example.com/var/opt/gitlab/git-data/repositories/git/my_webservers_TEST.git

 Insert picture description here


2. Authorize... As required

 Insert picture description here


3. Create job templates as required

 Insert picture description here
 Insert picture description here


4. Authorize... As required .

 Insert picture description here


5. Update code .

[[email protected] ~]$ cd ~/git-repos[[email protected] git-repos]$ git clone  http://git.lab.example.com:8081/git/my_webservers_TEST.git[[email protected] git-repos]$ cd my_webservers_TEST[[email protected] my_webservers_TEST]$ vim templates/index.html.j2{{ apache_test_message }} {{ ansible_distribution }} {{ ansible_distribution_version }} <br>Current Memory: {{ ansible_facts.memtotal_mb }} <br>Current Free Memory: {{ ansible_facts.memfree_mb }} <br>Current Host: {{ ansible_hostname }} <br>Server list: <br>{% for host in groups['all'] %}{{ host }} <br>{% endfor %}[[email protected] my_webservers_TEST]$ git add templates/index.html.j2[[email protected] my_webservers_TEST]$ git commit -m "Added Ansible facts"[[email protected] my_webservers_TEST]$ git push

6. Update the project and start the job .

 Insert picture description here
 Insert picture description here


7. verification .

[[email protected] ~]$ curl servercThis is a test message RedHat 8.0 <br>Current Memory: 821 <br>Current Free Memory: 197 <br>Current Host: serverc <br>Server list: <br>serverd.lab.example.com <br>serverc.lab.example.com <br>[[email protected] ~]$ curl serverdThis is a test message RedHat 8.0 <br>Current Memory: 821 <br>Current Free Memory: 195 <br>Current Host: serverd <br>Server list: <br>serverd.lab.example.com <br>serverc.lab.example.com <br>

8. score .

[[email protected] ~]$ lab provision-review grade


summary

RHCA Certification requires experience 5 Study and examination of the door , It still takes a lot of time to study and prepare for the exam , Come on , Can GA 🤪.

That's all 【 Brother goldfish 】 Yes Chapter nine Manage projects and carry out operations – Create a job template and start the job Brief introduction and explanation of . I hope it can be helpful to the little friends who see this article .

Red hat Certification Column series :
RHCSA special column : entertain RHCSA authentication
RHCE special column : entertain RHCE authentication
This article is included in RHCA special column :RHCA memoir

If this article 【 article 】 It helps you , I hope I can give 【 Brother goldfish 】 Point a praise , It's not easy to create , Compared with the official statement , I prefer to use 【 Easy to understand 】 To explain every point of knowledge with your writing .

If there is a pair of 【 Operation and maintenance technology 】 Interested in , You are welcome to pay attention to ️️️ 【 Brother goldfish 】️️️, I will bring you great 【 Harvest and surprise 】!

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206271746572437.html

随机推荐