Amazon Linux 2 ile Lightsail örneğine CodeDeploy yüklenemiyor

Oct 02 2020

Yalnızca Amazon Linux'u kullanabilmekten (Amazon Linux 2'yi de kullanmak istiyordu) pek memnun olmadığından , her iki işletim sistemi sürümünü kullanarak ve aynı betiği ekleyerek iki örnek oluşturdu.

mkdir /etc/codedeploy-agent/

mkdir /etc/codedeploy-agent/conf

cat <<EOT >> /etc/codedeploy-agent/conf/codedeploy.onpremises.yml

---

aws_access_key_id: ACCESS

aws_secret_access_key: SECRET

iam_user_arn: arn:aws:iam::525221857828:user/GeneralUser

region: eu-west-2

EOT

wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install

chmod +x ./install

sudo ./install auto

İkisi arasında fark ettiğim fark, Linux 2'ye sahip örnekte, klasörün /etc/codedeploy-agent/conf/yalnızca bir dosyaya sahip olmasıdır.

ve Linux'ta iki dosya var

Bunu bilerek, Linux 2 örneğinde aynı ada sahip yeni bir dosya oluşturdum

touch codedeployagent.yml

, izinlerini değiştirdi

-rw-r--r-- 1 root root 261 Oct  2 10:43 codedeployagent.yml

-e

-rwxr-xr-x 1 root root 261 Oct  2 10:43 codedeployagent.yml

ve aynı içeriği ekledi

:log_aws_wire: false
:log_dir: '/var/log/aws/codedeploy-agent/'
:pid_dir: '/opt/codedeploy-agent/state/.pid/'
:program_name: codedeploy-agent
:root_dir: '/opt/codedeploy-agent/deployment-root'
:verbose: false
:wait_between_runs: 1
:proxy_uri:
:max_revisions: 5

ve sonra makineyi yeniden başlattı. Yine de bu, çalıştırdığım zamanki gibi sorunu çözmedi

sudo service codedeploy-agent status

hala alacak

Deploy-agent.service kodlu / bin / systemctl durum kodlu yeniden yönlendiriliyor Ünite kodlanmışeploy-agent.service bulunamadı.

Ayrıca tüm güncellemelerin yerinde olmasını sağladı, makineyi yeniden başlattı, ancak bu da işe yaramadı.

Yanıtlar

2 Marcin Oct 02 2020 at 11:42

CodeDeployGitHubDemo'yu dağıtmak için Amazon Linux 2 bulut sunucuları kurulumumun ayrıntılarını sağlayabilirim (geçmiş soruya göre ).

1. CodeDeploy aracısı

Aşağıdakileri şu şekilde kullandık UserData(değilse bölgeyi ayarlamanız gerekebilir us-east-1):

#!/bin/bash

yum update -y
yum install -y ruby wget

cd /home/ec2-user

wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install

chmod +x ./install
./install auto

Sabit kodlama kimlik bilgileri gerektirmedi. Aşağıdakiler, kullandığım Amazon Linux 2örneklerde mükemmel çalışıyor .

2. Örnek rolü

Örneğinizin CodeDeploy için uygun bir role ihtiyacı var. Burada listelenen politikayla bir EC2 bulut sunucusu rolü kullandım :

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:Get*",
                "s3:List*"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}

3. Dağıtım grubu

Bir AutoScaling grubunda testler için üç örneğim vardı myasg:

4. Dağıtım

S3'ten Load Balancer olmadan dağıttım:

5. Sonuçlar

Hiçbir sorun bulunamadı ve dağıtım başarılı oldu:

Ve çalışan web sitesi (güvenlik gruplarında 80 numaralı bağlantı noktasını açmanız gerekir):

Güncelleme

Amazon Linux üzerinde manuel kurulum için 2. sudo su -Oturum açtıktan sonra root olabilirsiniz .

mkdir -p /etc/codedeploy-agent/conf

cat <<EOT >> /etc/codedeploy-agent/conf/codedeploy.onpremises.yml
---

aws_access_key_id: ACCESS

aws_secret_access_key: SECRET

iam_user_arn: arn:aws:iam::525221857828:user/GeneralUser

region: eu-west-2

EOT

yum install -y wget ruby

wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install

chmod +x ./install

env AWS_REGION=eu-west-2 ./install rpm

Durumunu kontrol etmek için:

systemctl status codedeploy-agent

Bununla böyle bir şey almalısın

● codedeploy-agent.service - AWS CodeDeploy Host Agent
   Loaded: loaded (/usr/lib/systemd/system/codedeploy-agent.service; enabled; vendor prese
t: disabled)
   Active: active (running) since Sat 2020-10-03 07:18:57 UTC; 3s ago
  Process: 3609 ExecStart=/bin/bash -a -c [ -f /etc/profile ] && source /etc/profile; /opt
/codedeploy-agent/bin/codedeploy-agent start (code=exited, status=0/SUCCESS)
 Main PID: 3623 (ruby)
   CGroup: /system.slice/codedeploy-agent.service
           ├─3623 codedeploy-agent: master 3623
           └─3627 codedeploy-agent: InstanceAgent::Plugins::CodeDeployPlugin::CommandPo...

Oct 03 07:18:57 ip-172-26-8-137.eu-west-2.compute.internal systemd[1]: Starting AWS Cod...
Oct 03 07:18:57 ip-172-26-8-137.eu-west-2.compute.internal systemd[1]: Started AWS Code...
Hint: Some lines were ellipsized, use -l to show in full.

Eğer koşarsan

sudo service codedeploy-agent status

alacaksın (yani beklendiği gibi çalışıyor)

The AWS CodeDeploy agent is running as PID 3623

Çalışmıyorsa başlamak için:

systemctl start codedeploy-agent