Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Construction of Ansible development environment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Ansible is a new automatic operation and maintenance tool. Based on Python development, it integrates the advantages of many operation and maintenance tools (puppet, cfengine, chef, func, fabric), and realizes the functions of batch system configuration, batch program deployment, batch running commands and so on.

Building steps

First, create a virtual machine

1. Install VirtualBox

2. Install Vagrant

3. Use Vagrant to install and configure the virtual machine

Install Ansible on the virtual machine

1. Install Ansible

Third, install VS Code

1. Install Visual Studio Code

The building environment is win10.

First, create a virtual machine

1. Install VirtualBox1.1 installation package to download this virtual machine using the

Vargrant is created based on VirtualBox. After downloading the installation package, click the next step to install it. A successful installation will generate a shortcut icon in the following image on the desktop.

1.2 after the installation is complete, open the VirtualBox software, open the management global settings, change the default virtual computer location to another disk, and do not put it on disk C.

2. Download the Vagrant2.1 installation package, double-click run, and click next. After the installation is successful, type in the CMD command line.

Vagrant version. As shown in the figure below, the installation is successful.

2.2 install the vbguest plug-in, command:

Vagrant plugin install vagrant-vbguest

2.3 Vagrant command details the operation of vagrant box add adding box vagrant init initializes the box operation, will generate the configuration file of vagrant Vagrantfilevagrant up starts the local environment vagrant ssh through ssh login to the local environment virtual machine vagrant halt shuts down local environment vagrant suspend pauses local environment vagrant resume resumes local environment vagrant reload modifies Vagrantfile and makes it effective (equivalent to halt first Then up) vagrant destroy completely removes the local environment vagrant box list displays the list of box that has been added vagrant box remove deletes the corresponding boxvagrant package packaging command, you can package the current running virtual machine environment vagrant plugin to install the uninstall plug-in vagrant status to get the status of the current virtual machine vagrant global-status to display all the environment status of the current user Vagrant, use Vagrant installation and configuration virtual machine 3.1 to add box command:

Next, we need to choose which operating system to use, taking ubuntu12.04.5 as an example. In the previous virtual machine-based workflow, we need to download the ISO image, install the system, set up the system and so on. The Vagrant open source community provides many packaged operating systems, which we call box. You can download it from the Internet and find the box you want, or you can make one yourself.

Vagrant box add ubuntu/precise64

Ubuntu/precise64 is the name of the downloaded box image

3.2 initialize the virtual machine

Vagrant init ubuntu/precise64

3.2.1 after initialization, the Vagrantfile file is generated in the current directory, as shown below

3.3 start the virtual machine

Vagrant up

3.4 enter the virtual machine

Vagrant ssh

3.5 package Box

3.5.1. After the packaging is completed, a Ubuntu12_04.box file will be generated in the current directory and distributed to other users (developers). Other users only need to add the box and initialize their own development directory to get an identical development environment. 3.5.2. First, execute exit to exit the virtual machine interface.

3.5.3, then execute vagrant halt to shut down the Ubuntu system

3.5.4. Execute vagrant status to confirm that Ubuntu has been shut down.

3.5.5. Execute the command to package and complete the package, and a Ubuntu12_04.box file will be generated in the current directory

Vagrant package-output Ubuntu12_04.box

3.5.6. If other colleagues need to use the virtual machine, you only need to do the following. In this demonstration, use another directory demonstration. The command is to add the previously packaged box to the local environment, first execute the command: vagrant box add Ubuntu12_04 Ubuntu12_04.box

3.5.6.1 then initialize the imported virtual machine. If the Vagrantfile file has already been created in the current directory, change to another directory. This article uses the D:\ VS1 directory with initialization command: vagrant init Ubuntu12_04

3.5.6.2 start the virtual machine

Vagrant up

Install Ansible on the virtual machine

1. Install Ansible1.1 to download the pip installation package with the following command: curl https://bootstrap.pypa.io/get-pip.py-o get-pip.py

1.2 use the python command to install the pip command. Python is already installed on the default system. The installation command is as follows: sudo python get-pip.py

Use pip-- version to see if the installation is successful

1.3Then you use the pip command to install ansible, you must first switch to the root user to prevent reporting various permission issues

Su-root then enters the root user password, and the default password is vagrant

1.4 execute the ansible installation command pip install ansible==2.7.1-trusted-host mirrors.aliyun.com-index-url= http://mirrors.aliyun.com/pypi/simple/

1.5 after the installation is complete, enter the ansible-- version command to see if it is successful.

Third, install VS Code

1. Download the installation package and click next to install all the time. After the installation is successful, the icon will appear on the desktop.

2. When the installation is complete, enter the main interface, press the shortcut key ctrl+shift+x to enter the resource expansion page, enter language, and install the simplified Chinese language to facilitate the use of the software. Restart is required after installation is completed.

3. Click "create a new file" and enter the code

4. Click on the editor and press F5 to debug

5. Click the Settings button to add different debug configurations, such as js,c++

    if the article is helpful to you, you can click on the follow function in the lower right corner. Welcome to forward and clap the brick. I will continue to launch articles related to the test and share the testing technology with you. Every original article is written attentively to put an end to plagiarism and copying. The official Wechat account is synchronized with the articles on this platform for easy reference.

QQ technology exchange group: please enter the verification information 51CTO to add the group.

Wechat QR code follow official account:

After following, reply to the resource download, and you can get the download address of all kinds of resources shared by yourself.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report