Before I had summed up a little Ansible series Bowen, this article also take the previous space bar. In the current network application, the security-hardened host is not allowed to log in directly to the root user, and many commands require root users to perform, without rebuilding the current network. Hope that through a common user first landing, and then Su-c
tosee if our module needs to perform any changes.4. We check if we were sent a new hostname to set, and check if that hostnameis different from the one that is currently set.5. If both those tests are true, we try to change the hostname, and set CHANGEDto True .6. Finally, we output the results and exit. This includes the current hostnameand whether we made changes or not.The above script executes the following operations:
Changing the hostname on a Unix machine requires root privileges. So w
want to operate on different operating systems
Prompt the user and then execute the operation request
When you execute a query task that requires a long time
Update prohibited when hard disk space exceeds the threshold
Check whether the custom script is running
Task delegationAnsible, by default, runs its tasks all at once on the configured machine. This is greatwhen you have a whole bunch of separate machines to configure, or if each of yourma
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
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
: indicates that the key storage path is $ {USER}/. ssh/id_dsa.
6> copy the public key on 250 to the controlled client.
# Ssh-copy-id-I ~ /. Ssh/id_rsa.pub root@192.168.1.251Option-I: Specify the Public Key File
# Try to log on without a password in ssh 192.168.1.6.2
7> 250 basic ANSIBEL Test
# Ansible storm_cluster-m command-a 'uptime'
Note: during the first running, you need to enter "yes" for public ke
Sesame HTTP: Ansible extension and sesame ansible ExtensionIntroduction to Ansible
Ansible is an O M tool developed by Python. Because work requires access to Ansible, it often integrates some things into Ansible, so it is more
of pageInstalling AnsibleIf you are a centos/redhat, Debian, Ubuntu user, you can use the System Package Manager yum or Apt-get installation (Centos/redhat need to install Epel package to install via Yum). But here, I strongly recommend that you use PIP to install Ansible. So what is PIP? Pip is a Python package installation and management tool that features a gem of NPM, Ruby, similar to node. js. Pip mak
on the management node:This article installs ansible on the CentOS 6.5 system via Yum and the Epel source is already installed on the machine, please refer to the official documentation for other system installation methods.[Email protected] ~]# yum-y install ansibleCommon configuration items in the ansible configuration file:[defaults]inventory =/etc/ansible/ho
If you do not have written authorization, do not reprint it.
Chapter 4 Use of ansible in large projects
New features in 1.3There are two features in Ansible 1.3 that were alluded to previously in the chapter.The first feature is the metadata roles. They allow you to specify that your roledepends on other roles. For example, if the application that you are deploying needsto send mail, your role could depend
lanzhiyong -m shell -a ‘ls /scripts‘192.168.209.13 | SUCCESS | rc=0 >>a.shtest.sh
Group of 16.ansible Common modulesThe group module is used to add or remove groups on the managed machine//在受控机上添加系统组,其gid为306,组名为mysql[[emailprotected] ~]# ansible lanzhiyong -m group -a ‘name=mysql system=yes gid=306 state=present‘192.168.209.13 | SUCCESS => { "changed": false, "gid": 306, "name":
remotely using SSH, and the SSH service is a server prerequisite. Ansible simplifies the use of cost on the design and uses SSH to connect "managed nodes" on the "Management node". By creating an SSH connection to send the order and execution, to achieve the purpose of configuration management. This avoids compatibility issues with the use of agents in different versions of the operating system, or even under different operating systems of the releas
configure SSH trust, otherwise you will be prompted to enter the password.ssh-keygen -t rsa //生成密钥[[emailprotected] ~]# ls .ssh/id_rsa id_rsa.pubssh-copy-id -i ~/.ssh/id_rsa.pub [emailprotected](需要免密的受控端ip)Ansible How to get helpAnsible to obtain help information through the Ansible-doc command, you can use the-s option of this command to get help for the specified module//查询ping模块的帮助文档[[emailprotecte
. 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
:?? The task script (Task Set) orchestrates and defines the configuration files of the ansible task set, which are executed sequentially by ansible, usually in the yml file in JSON format.2. inventory:?? Ansible manages the host list/etc/anaible/hosts.3. modules:?? Most of the functional modules used by ansible to exec
can bedone with the init command.The first step is to figure out what arguments and features the module supports. Forthe sake of simplicity, let's have our module only accept one argument. We'll use theargument runlevel to get the runlevel the user wants to change to. To do this, weinstantiate the AnsibleModule class with our data.module = AnsibleModule(argument_spec = dict(runlevel=dict(default=None, type='str')))
You can also parse parameters and o
documentation for the specified moduleUse of the seven Ansible playbookThe equivalent of writing the module to the configuration file,Example 1:VI/ETC/ANSIBLE/TEST.YML//Add the following:---- hosts: lvlinux-2 remote_user: root tasks: - name: test_playbook shell: touch /tmp/lvlinux.txtNote: The first line needs to have three bars, the hosts parameter specifies which hosts to participate in, if mor
Ansible learning-ansible
Ansible technologies (Automated O M tools) are developed based on python.
Installation methods include yum, apt, pip, etc.
For example, pip: pip install ansible
The only requirement of ansible for the client is to have SSH and Python (if the python
= path: specify inventory information. Default Value:/etc/ansible/hosts; 4-F num, -- forks = num: number of concurrent threads; default value: 5; 5 -- private-Key = private_key_file: specify the key file; 6-M name, -- module-name = Name: Specify the module used for execution;
Tip:-M specifies the module name. By default, it refers to the command module, which can be omitted without writing.
1-M directory, -- module-Path = Directory: Specifies the mod
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 and
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.