1
resposta

[Dúvida] apt-get apresenta falhas

Olá,

Venho tendo problemas ao executar o playbook.yml, quando deixo a opção update_cache: yes recebo as seguintes mensagens de erro:

TASK [Instalando o Python 3 e Virtualenv] **************************************
fatal: [54.245.41.187]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: 
W:Failed to fetch http://security.ubuntu.com/ubuntu/dists/hardy-security/main/source/Sources  
404  Not Found [IP: 91.189.91.39 80]\n, W:Failed to fetch http://security.ubuntu.com/ubuntu/dists/hardy-security/main/binary-i386/Packages  
404  Not Found [IP: 91.189.91.39 80]\n, W:Failed to fetch http://security.ubuntu.com/ubuntu/dists/hardy-security/restricted/binary-i386/Packages  
404  Not Found [IP: 91.189.91.39 80]\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy/main/source/Sources 
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy/main/binary-amd64/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy/restricted/binary-amd64/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy/main/binary-i386/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy/restricted/binary-i386/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/main/source/Sources  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/restricted/source/Sources  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/main/binary-amd64/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/restricted/binary-amd64/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/main/binary-i386/Packages  
404  Not Found\n, W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/restricted/binary-i386/Packages  
404  Not Found\n, E:Some index files failed to download. They have been ignored, or old ones used instead."}

E mesmo executando diretamente pelo ssh o comando sudo apt-get update tenho erros com relação a isso:

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/hardy-security/main/binary-i386/Packages  404  Not Found [IP: 185.125.190.36 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/hardy-security/restricted/binary-i386/Packages  404  Not Found [IP: 185.125.190.36 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

Vi que poderiam ser falhas com relação ao mirror que o sistema utiliza, mas as soluções que procurei não funcionaram corretamente. Desativei a opção de realizar o apt-get update para realizar a instalação direta dos pacotes, mas ele não reconhece o python3:

❯ ansible-playbook playbook.yml -u ubuntu --private-key iac-alura.pem -i hosts.yml
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [terraform-ansible] ************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************
ok: [54.245.41.187]

TASK [Instalando o Python 3 e Virtualenv] *******************************************************************************************************
fatal: [54.245.41.187]: FAILED! => {"changed": false, "msg": "No package matching 'python3' is available"}

PLAY RECAP **************************************************************************************************************************************
54.245.41.187              : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Segue abaixo o codigo do playbook.yml:

- hosts: terraform-ansible
  tasks:
  - name: Instalando o Python 3 e Virtualenv
    apt:
      pkg:
      - python3
      - virtualenv
      update_cache: yes
    become: yes

E também do main.ts:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.27"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_instance" "app_server" {
  ami           = "ami-830c94e3"
  instance_type = "t2.micro"
  key_name = "iac-alura"
#   user_data = <<-EOF
#                 #!/bin/bash
#                 cd /home/ubuntu
#                 echo "<h1>Feito com Terraform</h1>" > index.html
#                 nohup busybox httpd -f -p 8080 &
#                 EOF
  tags = {
    Name = "Teste AWS"
  }
}
1 resposta

Oi, Ytalo. Tudo bem?

Você tentou mudar a AMI? Qual versão do Ubuntu é a dessa AMI que você está usando?

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software