gpt4 book ai didi

amazon-web-services - Ansible EC2 没有这样的文件或目录 : b'ssh': b'ssh'

转载 作者:行者123 更新时间:2023-12-02 16:22:35 42 4
gpt4 key购买 nike

我正在尝试将 dockerized React Web 应用程序部署到 EC2,但在配置实例时仍然出现错误。已经搜索但没有找到任何东西。

使用命令部署:

ansible-playbook -vvvvv ansible/ec2_deploy.yml --user ubuntu

我在其中运行 ansible 的 Docker:

FROM node:10.23.0-alpine3.9
COPY . .
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add --update ansible
RUN apk add
RUN pip install boto
RUN chmod 777 get_vault_pass.sh
ENTRYPOINT [ "/bin/sh" ]

Ansible 部署:

- name: Deploy to EC2
hosts: localhost
connection: local

tasks:
- name: Launch EC2 instance
ec2:
instance_type: t2.micro
image: ami-0885b1f6bd170450c
region: us-east-1
key_name: eshop-key-pair
vpc_subnet_id: subnet-cafc34fb
assign_public_ip: yes
wait: yes
count: 1
group: eshop
aws_access_key: 'key'
aws_secret_key: 'key2'
security_token: 'token'
register: ec2

- name: Add instance host to group
add_host: hostname={{ item.public_dns_name }} groupname=launched
with_items: '{{ec2.instances}}'

- name: Wait for SSH connection
wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=600 state=started
with_items: '{{ec2.instances}}'

- name: Configure EC2
hosts: launched
connection: ssh

tasks:
- name: Install docker
apt:
name: docker.io
state: present
update_cache: yes
become: yes
- service:
name: docker
state: started
enabled: yes
become: yes
- name: Get project files from GIT
git:
repo: 'https://github.com/romanzdk/4IT572_ZS_2020_circleci.git'
dest: ./app
- name: Build docker with eshop
shell: cd app && docker build -t myeshop:latest .
become: yes
- name: Run docker with eshop
shell: docker run -p 80:3000 myeshop
async: 90
poll: 15
become: yes
- wait_for: delay=60 timeout=600
port: 80

堆栈跟踪:


PLAY [Configure EC2] ***********************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************
task path: /ansible/ec2_deploy.yml:30
<ec2-100-25-28-7.compute-1.amazonaws.com> ESTABLISH SSH CONNECTION FOR USER: None
<ec2-100-25-28-7.compute-1.amazonaws.com> SSH: ansible.cfg set ssh_args: (-C)(-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<ec2-100-25-28-7.compute-1.amazonaws.com> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<ec2-100-25-28-7.compute-1.amazonaws.com> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<ec2-100-25-28-7.compute-1.amazonaws.com> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/root/.ansible/cp/aaee2dc684)
<ec2-100-25-28-7.compute-1.amazonaws.com> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/aaee2dc684 ec2-100-25-28-7.compute-1.amazonaws.com '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 140, in run
res = self._execute()
File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 612, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/lib/python3.6/site-packages/ansible/plugins/action/normal.py", line 46, in run
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 745, in _execute_module
self._make_tmp_path()
File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 294, in _make_tmp_path
tmpdir = self._remote_expand_user(tmpdir, sudoable=False)
File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 613, in _remote_expand_user
data = self._low_level_execute_command(cmd, sudoable=False)
File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 980, in _low_level_execute_command
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/ssh.py", line 1145, in exec_command
(returncode, stdout, stderr) = self._run(cmd, in_data, sudoable=sudoable)
File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/ssh.py", line 392, in wrapped
return_tuple = func(self, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/ssh.py", line 1035, in _run
return self._bare_run(cmd, in_data, sudoable=sudoable, checkrc=checkrc)
File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/ssh.py", line 790, in _bare_run
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: b'ssh': b'ssh'

fatal: [ec2-52-73-248-179.compute-1.amazonaws.com]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}

知道哪里出了问题吗?我已经在这上面花了很长时间...由于代码太长,我被要求添加更多详细信息,这里有更多文本,大声笑

最佳答案

chepner 的评论很准确——您的 docker 镜像没有安装 ssh。尝试

apk add openssh-client

并且应该解决错误。

关于amazon-web-services - Ansible EC2 没有这样的文件或目录 : b'ssh': b'ssh',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65225803/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com