Use ansible to compile and install the O & M tools tmux and ansibletmux

Source: Internet
Author: User

Use ansible to compile and install the O & M tools tmux and ansibletmux

Experimental System: CentOS 6.6 _ x86_64

Prerequisites: Prepare the compiling environment in advance, and disable both firewall and selinux.

Software Introduction: tmux is an excellent terminal multiplexing software, similar to GNU Screen, but comes from OpenBSD and adopts BSD authorization. The most intuitive advantage of using it is that after logging on to the remote host through a terminal and running tmux, you can enable multiple consoles without having to "waste" Additional terminals to connect to this remote host. Of course, its functions are far more than that.

Download: http://pan.baidu.com/s/1c0i9kf2

1. General Installation

1. dependencies required for installing tmux:

wget https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gztar xf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configuremake && make install
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

2. Install the tmux package:

wget http://iweb.dl.sourceforge.net/project/tmux/tmux/tmux-2.0/tmux-2.0.tar.gztar xf tmux-2.0.tar.gzcd tmux-2.0./configure --prefix=/usr/local/tmuxmake && make install

3. Export the binary file:

vim /etc/profile.d/tmux.sh---------------------------------------->PATH=$PATH:/usr/local/tmux/binexport PATH<----------------------------------------. /etc/profile.d/tmux.sh

4. Export man manual:

Vim/etc/man. config -----------------------------------------------> MANPATH/usr/local/tmux/share/man // Add a row

5. Edit the configuration file:

Vim ~ /. Tmux. conf ----------------------------------------> set-g prefix C-a // set the prefix command to crtl + aunbind C-B // unbind ctrl + B from setw-g mode-keys vi/copy -mode set shortcut to vi mode set-g default-terminal "screen-256color" // set terminal color to 256 color set-g status-utf8 on // enable the uft-8 for the status bar support set-window -option-g mode-mouse on // enable scrolling

6. Common shortcut keys:

    

    

    

So far, the installation of tmux is complete. Next we will conduct an expansion experiment to use ansible to install tmux!

Ii. Expand the experiment

1. Install ansible and create the yaml file:

Yum-y install ansiblemkdir-pv/root/ansible. roles/roles // create the working directory cd/root/ansible. rolesvim tmux. yaml ---------------------------------------->-name: install tmux remote_user: root // host for running user hosts: tmux // The host for running the script. The roles:-tmux // rule name is defined later, name of the folder to be created later

2. Put the file:

Cd/root/ansible. roles/rolesmkdir-pv tmux/{files, handlers, tasks} // create a folder with the same name as the rule cp/root/tmux-2.0.tar.gz/root/libevent-2.0.22-stable.tar.gz tmux/files // put the installation package into cp/root /. tmux. conf tmux/files // put the configuration file

3. Compile the main yaml file:

vim /root/ansible.roles/roles/tmux/tasks/main.yaml------------------------------------------------------>- name: copy libevent package
  copy: src=libevent-2.0.22-stable.tar.gz dest=/root
- name: copy tmux package
  copy: src=tmux-2.0.tar.gz dest=/root
- name: copy conf
  copy: src=.tmux.conf dest=/root
- name: run script
  script: tmux.sh

4. Compile the script tmux. sh:

vim /root/ansible.roles/roles/tmux/files/tmux.sh---------------------------------------------------------------->#!/bin/bash## Install libeventcd && cdtar xf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configuremake && make installln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5# Install tmuxcd && cdtar xf tmux-2.0.tar.gzcd tmux-2.0./configure --prefix=/usr/local/tmuxmake && make install# Extra Operationtouch /etc/profile.d/tmux.sh echo 'PATH=$PATH:/usr/local/tmux/bin' > /etc/profile.d/tmux.shecho 'export PATH' >> /etc/profile.d/tmux.shecho 'MANPATH /usr/local/tmux/share/man' >> /etc/man.config
. /etc/profile.d/tmux.sh
<----------------------------------------------------------------
chmod +x /root/ansible.roles/roles/tmux/files/tmux.sh

5. Add the host to be installed:

Vim/etc/ansible/hosts --------------------------------------------> [tmux] // corresponding to the name 192.168.19.76 ansible_ssh_pass = password in the tmux. yaml file // host IP + logon password

6. Try to use:

cd /root/ansible.roles/ansible-playbook tmux.yaml

    

Now, all the labs have been completed. In use, the file/etc/profile. d/tmux. sh cannot be normally source, so you may need to manually execute./etc/profile. d/tmux. sh. Due to time constraints, the process is not perfect, the script is not rigorous, there are no conditions to judge, and so on, and the installation of the host must have a compilation environment. If necessary, you can expand and modify the file by yourself. I have uploaded the ansible folder to the shared file. You can download and use it as needed. Finally, thank you for watching. Thank you! If you have any questions, contact QQ: 82800452.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.