-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Intermittent Server Connectivity Issue in Terraform and Ansible Configuration #910
Comments
Hey @spham can you post the exact error message you get? What is the content of your playbook? |
hi sorry for delay :
|
# only one playbook.yml
---
- name: Install Symfony development environment
hosts: all
become: true
vars:
docker_arch: amd64
git_user: "xxxxx"
git_email: "yyyyyyy@zzz.com"
tasks:
- name: Wait for SSH to be available
wait_for:
host: "{{ inventory_hostname }}"
port: 22
delay: 10
timeout: 120
- name: Fail if not an x86_64 architecture
ansible.builtin.fail:
msg: "This playbook is intended only for x86_64 (amd64) architectures."
when: ansible_architecture != "x86_64"
- name: Update and upgrade all packages to the latest version
ansible.builtin.apt:
update_cache: true
upgrade: dist
cache_valid_time: 3600
- name: Install required packages
ansible.builtin.apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- software-properties-common
- git
- build-essential
- zip
- name: Create directory for Docker's GPG key
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
- name: Add Docker's official GPG key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /etc/apt/keyrings/docker.gpg
state: present
- name: Print architecture variables
ansible.builtin.debug:
msg: "Architecture: {{ ansible_architecture }}, Codename: {{ ansible_lsb.codename }}"
- name: Add Docker repository
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ docker_arch }}
signed-by=/etc/apt/keyrings/docker.gpg]
https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
filename: docker
state: present
- name: Install Docker and related packages
ansible.builtin.apt:
name: "{{ item }}"
state: present
update_cache: true
loop:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
- name: Add Docker group
ansible.builtin.group:
name: docker
state: present
- name: Add user to Docker group
ansible.builtin.user:
name: "{{ ansible_user }}"
groups: docker
append: true
- name: Enable and start Docker services
ansible.builtin.systemd:
name: "{{ item }}"
enabled: true
state: started
loop:
- docker.service
- containerd.service
- name: Installer Git
ansible.builtin.apt:
name: git
state: present
- name: Install PHP 8.3 repository
ansible.builtin.apt_repository:
repo: ppa:ondrej/php
state: present
- name: Install PHP 8.3
ansible.builtin.apt:
name: php8.3
state: present
- name: Install PHP 8.3 extentions (for Laravel)
ansible.builtin.apt:
name: "{{ item }}"
state: present
loop:
- php8.3-xml
- php8.3-mbstring
- php8.3-intl
- php8.3-mysql
- php8.3-curl
- php8.3-redis
- php8.3-zip
- php8.3-gd
- php8.3-bcmath
- php8.3-imagick
- php8.3-xdebug
- php8.3-ldap
- php8.3-amqp
- php8.3-sqlite3
- name: Setup Symfony CLI
ansible.builtin.shell: curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
args:
creates: /usr/local/bin/symfony
- name: Install Symfony CLI
ansible.builtin.apt:
name: symfony-cli
state: present
- name: Install Composer
ansible.builtin.shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
args:
creates: /usr/local/bin/composer
- name: Add NodeSource repository
ansible.builtin.shell: curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
- name: Install Node.js
apt:
name: nodejs
state: present
- name: Mettre à jour npm
ansible.builtin.shell: npm install -g npm@latest
- name: Configuration de Git
ansible.builtin.shell: |
git config --global user.name "{{ git_user }}"
git config --global user.email "{{ git_email }}"
- name: Add non-privileged user
ansible.builtin.user:
name: dev
state: present
shell: /bin/bash
create_home: yes
- name: Add user to sudoers
ansible.builtin.copy:
content: "dev ALL=(ALL) NOPASSWD: ALL"
dest: /etc/sudoers.d/dev
mode: "0440"
- name: Install Laravel Installer
become: true
become_user: dev
shell: composer global require laravel/installer
args:
creates: /home/dev/.composer/vendor/bin/laravel
- name: Add user to Docker group
ansible.builtin.user:
name: dev
groups: docker
append: true
- name: Create SSH directory
ansible.builtin.file:
path: /home/dev/.ssh
state: directory
owner: dev
group: dev
mode: "0700"
- name: Copy SSH public key to non-privileged user
ansible.builtin.copy:
src: ~/.ssh/id_rsa.pub
dest: /home/dev/.ssh/authorized_keys
owner: dev
group: dev
mode: "0600"
- name: Copy SSH private key to non-privileged user
ansible.builtin.copy:
src: ~/.ssh/id_rsa
dest: /home/dev/.ssh/id_rsa
owner: dev
group: dev
mode: "0600"
- name: Add Firewall rules
ansible.builtin.apt:
name: ufw
state: present
- name: By default, deny all incoming connections
ansible.builtin.shell: ufw default deny incoming
- name: By default, allow all outgoing connections
ansible.builtin.shell: ufw default allow outgoing
- name: Allow SSH anywhere
ansible.builtin.shell: ufw allow OpenSSH
- name: Enable UFW
ansible.builtin.shell: ufw --force enable |
This is the only error I saw in your logs:
This is an error coming from the FWIW, while testing this locally, I found that I have the same error when This error does not match your initial description ( Some general suggestions:
|
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
What happened?
Hello, I'm encountering an issue when executing the code, it results in an error stating that the server is unreachable.
I've added wait times, but it didn't solve the issue. Interestingly, when I manually rerun it a second time, it works, or it also works when I perform a terraform test.
Can someone help diagnose the intermittent connectivity issue?
What did you expect to happen?
I expect it to work consistently, not just randomly.
for exemple, this mornging I try once, and it's ok
Please provide a minimal working example
Here is the code:
The text was updated successfully, but these errors were encountered: