[test]
0.0.0.0 ansible_ssh_user=test ansible_ssh_pass=123445 ansible_sudo_pass=123445
0.0.0.0 ansible_ssh_user=test ansible_ssh_pass=123445 ansible_sudo_pass=123445
- hosts: '{{ do_hosts }}' remote_user: test tasks: - name: copy ssh key authorized_key: user: test key: "{{ lookup('file', '/home/test/.ssh/id_rsa.pub') }}" - name: nopassword for test on the remote hosts action: shell sed "s/^#\ %wheel.*NOPASSWD:\ ALL/%wheel\ ALL=(ALL)\ NOPASSWD:\ ALL/" -i /etc/sudoers sudo: yes - name: sudo no tty for test on the remote hosts shell: sed -i '/Defaults.*requiretty/a\ Defaults:\ test\ !requiretty' /etc/sudoers shell: sed -i "$ a Defaults\:\ test\ !requiretty" /etc/sudoers sudo: yes - name: configuration ulimit params on the remote hosts action: shell sed -i '$ a fs.file-max = 65535' /etc/sysctl.conf && sed -i 's/1024/65535/' /etc/security/limits.d/90-nproc.conf && sed -i '$ a* soft nofile 65535\n* hard nofile 65535' /etc/security/limits.conf sudo: yes - name: update hostname action: shell sed -i 's/.localdomain//g' /etc/sysconfig/network && service network restart sudo: yes - name: copy localrepo action: copy src=/etc/yum.repos.d/localrepo.repo dest=/etc/yum.repos.d/ mode=0755 sudo: yes - name: install jdk action: yum name=jdk state=present sudo: yes
- name: install lrzsz
action: yum name=lrzsz state=present
sudo: yes
- name: install lsof
action: yum name=lsof state=present
sudo: yes - name: config java_home action: shell echo 'export JAVA_HOME=/usr/java/latest' >> /etc/profile sudo: yes - name: config hostname for hosts action: shell echo "{{ ansible_default_ipv4.address }} {{ ansible_hostname }}" >> /etc/hosts sudo: yes
- name: add kydev user
action: user name={{ item.name }} state=present password={{ item.new_pass | password_hash('sha512') }} update_password=always
with_items:
- { name: 'test',new_pass: '123456' }
sudo: yes
執行命令:java