From Ansible to a host that automatically performs an interactive installation upon connection
How do I connect successfully?
If you try to connect, you will see the interaction script output successfully in debug mode, but
The process stops and times out, perhaps because the command cannot be entered in that state.
Error message with -b option:
ERROR!Timeout(12s) waiting for privilege escalation prompt
The command (nmtui) is automatically executed, so I think it's okay to disable it, but I don't know how to disable it.
(I saw ~/.ssh/rcand/etc/ssh/sshrc)
Aug 20 14:02:30 ip-xxx-xxx-xxx-xxx-xxx.ap-northeast-1.compute.internal sudo [1240]: anon:TTY=pts/1; PWD=/home/anon; USER=root;COMMAND=nmtui
Ansible Commands
available test-mping --private-key test.pem-vvv
Ansible.log Excerpt
2018-08-19 14:31:19,003 p=3924 u=ec2-user | 3930 1534689079.00384:_low_level_execute_command() done:rc=0, stdout=, stderr=open terminal failed:not a terminal
2018-08-19 14:31:19,004p=3924u=ec2-user|39301534689079.00403:_low_level_execute_command():starting
2018-08-19 14:31:19,004p=3924u=ec2-user | 3930 1534689079.00418:_low_level_execute_command():executing: /bin/sh-c'/usr/bin/python/home/anon/.ansible/tmp/ansible-tmp-1534689078.9-276929/rb/expect.py
2018-08-19 14:31:19,029 p=3924u=ec2-user | 3930 1534689079.02952: stdout chunk (state=2): HERE IS TUI.
2018-08-19 14:31:54,887 p=3924 u=ec2-user | 3924 1534689114.88690: RUNNING CLEANUP 2018-08-19 14:31:54,888 p=3924 u=ec2-user | [ERROR]: User interrupt execution
linux centos ansible
For example, when performing Ansible via ssh login from PC1(centOS) to PC2(centOS), I don't think there was a particularly complicated configuration.
1, Ansible Folder Configuration Example
AnsibleRoot folder
private_keys
private_key_xxx
hosts
dev.txt
templates
selinux_config
main.yml
2, hosts/dev.txt
[dev]
192.168.X.XXX:22
3, main.yml Example
-name:install middleware
hosts —dev
tasks:
- name —disable selinux
become:yes
shell —bash setenforce0
ignore_errors —true
- name —set selinux/config
become:yes
template:
src —templates/selinux_config
dest: /etc/selinux/config
owner —root
group —root
mode —644
4,templetes/selinux_config
#This file controls the state of SELinux on the system.
# SELINUX=can take one of these three values:
# enforcement-SELinux security policy is enforced.
# permanent-SELinux prints warnings installed of enforcement.
# disabled-No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE=can take one of three two values:
# targeted-targeted processes are protected,
# minimum-Modification of targeted policy. Only selected processes are protected.
# mls-Multi Level Security protection.
SELINUXTYPE=targeted
5, What to do with PC1
(assuming that the user name being logged in can be sudoed in vagrant)
(Assume that the answer folder you created is located in /home/vagrant/vagrant_shared/ansible)
# sudo yum install epel-release
# sudo yum installable
# sudo yum install openssh-clients
cd/home/vagrant/vagrant_shared/ansable
cp private_keys / private_key../../
sudo chmod0600../../private_key
available-playbook-i hosts/dev.txt main.yml-uvagrant --private-key="../../private_key"
© 2024 OneMinuteCode. All rights reserved.