This is a creation in
Article, where the information may have evolved or changed.
Containers are an increasingly popular development environment. As a developer, you can choose from a variety of tools to manage your containers. This article will introduce you to Ansible Container and show you how to run and test your application in a similar production environment.
Entry
This example uses a simple Flask Hel
(IOException E1) { - theSystem.out.println ("output stream failed" +E1); - Wuyi e1.printstacktrace (); the - } Wu - } About $}Call#java Test CloudeployThe path to the playbook is fixed and can be passed in as a parameter.Execution Result:PLAY [hostname] ***************************************************************Gathering FACTS***************************************************************OK: [192.168.10.110]task: [Returnhostname] *******
I. Description of the EnvironmentServer with Ansible installed: 192.168.13.45Test environment server: 192.168.13.49/home/app/api-tomcat/webapps/api.war a new version of the war package location for the test environmentProduction Environment server: 192.168.13.51/home/app/api-tomcat/webapps/api.war for production Environment War package location/HOME/APP/API-TOMCAT/WEBAPPS/API for production environment Proj
I. Description of the EnvironmentServer with Ansible installed: 192.168.13.45Test environment server: 192.168.13.49/home/app/api-tomcat/webapps/api.war a new version of the war package location for the test environmentProduction Environment server: 192.168.13.51/home/app/api-tomcat/webapps/api.war for production Environment War package location/HOME/APP/API-TOMCAT/WEBAPPS/API for production environment Proj
, stdout_callback=results_callback, # use a custom callback instead of the "default" callback plug-in (if the Stdout_callback parameter is not required to output by default) ) result=tqm.run (play) finally: iftqmisnotnone:tqm.cleanup ()It's mine.. The contents of the/conf/hosts file are as follows:[Cephnode]192.168.89.136Attention:If inventory is not explicitly specified (the following parameters), the hosts will be read from the/etc/ansible/hosts by
writing modules, you should check ( )out the Ansible repository.If you want your module to work with a particular version, you should also switchto that version to ensure compatibility. The following commands will set you up todevelop modules for Ansible 1.3.0. Checking out the Ansible code gives you accessto a handy script that we will use later to
in the Device List group. It allows us to access all the hosts we configured at the same time. This is a very powerful tool, this allows us to review each host in the group and apply the operation above.
----Name: Configure the databaseHosts: dbserversUser: rootTasks:-Name: Install mysqlYum: name = {item} state = installedWith_items:-Mysql-server-MySQL-python
-Name: Start mysqlService: name = mysqld state = started enabled = true
-Name: Create a user for all app serversWith_items: groups. appse
Ansible @ an efficient configuration management tool-Ansible configure management-translation (4), ansible-ansibleDo not reprint without written permission
Due to the long content in Chapter 3, I will divide it into several parts for translation.
Advanced PlaybooksSo far the playbooks that we have looked at are simple and just run a number ofmodules in order.
Ansible @ an efficient configuration management tool-Ansible configure management-translation (8), ansible-ansibleIf you do not have written authorization, do not repeat Chapter 4. Use of Ansible in large projects
RolesIf your playbooks start expanding beyond what includes can help you solve, or youstart gathering a l
mysql_replication:login_user=root login_password={{Mysql_root_db_pass}} mode=startslave When:slave|faile D and mysql_repl_role = = ' slave ' and mysql_repl_master is defined The main.yml in the Tasks directory includes all the actions to be performed in Playbooks, each of which has a name for a simple description of the operation, and the tasks in this example include the following:
MySQL installation;
MySQL Administrator user root password modification;
MySQL configuration fi
Common module is used to execute commands on the remote host, and ansible by default is the command module. The Command module has a flaw in the ability to use the pipeline to conform to redirection. View the/tmp directory contents of the managed host [[emailprotected] ~]# ansible lanzhiyong-a ' ls/tmp ' 192.168.209.13 | SUCCESS | Rc=0 >>ansible_ Oul4esbad-blocks.txtcrontab.c055bofile1systemd-private-8499
a lot of related methods later on.By default, Ansible reads the list of hosts in the/etc/ansible file, in INI format. Each of the brackets represents a grouping, and the list of machines under it falls into this grouping until the next bracket is present. Typically we perform tasks by group, and the same set of managed servers applies the same configuration. A single server can also be attributed to multip
No written authorization. Do not reprint Chapter 5 custom Module
Using a moduleNow that we have written our very first module for Ansible, we should give it ago in a playbook. Ansible looks at several places for its modules: first it looks at theplace specified in the library key in its config file ( /etc/ansible/ansible.cfg ),next it will look in the location s
. Configuring the Host InventoryAnsible by reading the default host manifest file/etc/ansible/hosts, the file is specified in the/etc/ansible/ansible.cfg file, can be customized host, support IP, domain name, support grouping, convenient for aHosts or a group of identical hosts, and a default all group that represents all the hosts in the inventory.# vi/etc/ansible
/test.shJoin content #!/bin/bash echo `date` > /tmp/ansible_test.txtThen distribute the script to each machine.ansible testhost -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"Finally, the shell script is executed in bulkansible testhost -m shell -a "/tmp/test.sh"Shell module, also supports remote execution of commands and with pipelinesansible testhost -m shell -a "cat /etc/passwd|wc -l "Five Ansible Management task planansible testhost -m c
/bash192.168.154.133 | CHANGED | rc=0 >> //这是第二台被控主机yihong:x:1000:1000:yihong:/home/yihong:/bin/bashtest01:x:1001:1001::/home/test01:/bin/bashtest02:x:306:306::/home/test02:/bin/bashCron Module
The cron module in Ansible is used to define task schedules. There are two states (state): present means Add (omit does not write by default), and absent means remove.
1 • Add Scheduled Tasks[[emailprotected] ~]#
first and see how the two hosts are connected.ansible web_server -m ping(2) See which hosts are under the Web_server groupansible web_server --list(3) View memory usage of a host computerCommand format: Ansible Note: Execute a command using the-a parameter followed by the shell commandansible 192.168.2.205 -a "free -h"(4) Batch Create a regular user in the Web_server groupansible web_server -a "useradd andy"(5) Restart the HTTPD service for all hosts
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.