Common commands related to Ansible tools

Source: Internet
Author: User

uat(installed on 214, performed on 214):

Cat/etc/ansible/hosts

Added group:

[HDP]

172.30.64.214 Ansible_ssh_user=root

172.30.64.213 Ansible_ssh_user=root

172.30.64.216 Ansible_ssh_user=root

172.30.64.220 Ansible_ssh_user=root

Test:

Ansible hdp-m Ping

172.30.64.220 | Success >> {

"Changed": false,

"Ping": "Pong"

}

172.30.64.213 | Success >> {

"Changed": false,

"Ping": "Pong"

}

172.30.64.216 | Success >> {

"Changed": false,

"Ping": "Pong"

}

172.30.64.214 | Success >> {

"Changed": false,

"Ping": "Pong"

}

Common file operation commands:

Copy file (performed on 214):

Ansible hdp-m copy-a "Src=/etc/ansible/test.txt dest=/tmp/"

Copy the test directory under/TMP to the TMP directory for all nodes in the HDP group:

Ansible hdp-m copy-a "Src=/tmp/test dest=/tmp/"

You can also specify the owning user group as a copy:

Ansible hdp-m copy-a "src=/tmp/test dest=/tmp owner=hdfs Group=hadoop"

To delete a file:

Ansible hdp-m file-a "Dest=/tmp/test.txt state=absent"

To change file permissions:

Ansible hdp-m file-a "Dest=/tmp/test.txt mode=777"

To change the users and groups to which a file belongs:

Ansible hdp-m file-a "Dest=/tmp/test.txt owner=hdfs group=hadoop"

To create a directory:

Ansible hdp-m file-a "dest=/tmp/test owner=hdfs group=hadoop state=directory"

To create a file:

Ansible hdp-m file-a "dest=/tmp/test/1.txt owner=hdfs group=hadoop State=touch"

Pat(mounted on 36 nodes):

Several groups have been configured in the Hosts file, where 25-34 is a node in the SOLR group

Ansible storm-m shell-a ' grep 6226930000997489/var/log/storm/notify-20151231-135801-12-1451541482*log '

Ansible datanode-m shell-a "NETSTAT-TUNLP |grep 8986"-u Root

Ansible hdp-m shell-a "chmod 777/root/tcp_monitor.sh"-u Root

Ansible hdp-m shell-a "sh/root/tcp_monitor.sh"-u Root

Ansible storm-m shell-a ' grep 3015/var/log/storm/notify-20160331-235433* '


Ansible datanode-m shell-a "Netstat-n|awk '/^tcp/{++s[$NF]} END {for (a in S) print A,s[a]} '"-U Root


Ansible hdp-m copy-a "src=/root/tcp_monitor.sh dest=/root/tcp_monitor.sh owner=root group=root"
Ansible hdp-m shell-a "chmod 777/root/tcp_monitor.sh"-u Root

Common commands related to Ansible tools

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.