Skip to main content

Posts

antigravity agy failed to login, it's always DNS

On one cool mid summer not so good day, agy suddenly failed to login with error: Got an error: token exchange failed: Post "https://oauth2.googleapis.com/token": dial tcp: lookup oauth2.googleapis.com: no such host So it clearly is a network issue, but what? It is NOT DNS $ dig oauth2.googleapis.com +short 142.251.8.95 dig works, so it is NOT DNS, right? But ping / curl fail: $ ping -c1 oauth2.googleapis.com -t 2 zsh: alarm ping -c1 oauth2.googleapis.com -t 2 $ curl -v https://oauth2.googleapis.com --max-time 5 * Resolving timed out after 5005 milliseconds * Closing connection curl: (28) Resolving timed out after 5005 milliseconds And both error messages from agy and curl says "lookup"/"resolve", it must be DNS. It must be DNS A search for dial tcp: lookup no such host return a Go issue https://github.com/golang/go/issues/41425 . AI would also very good at detect language used base on error message. agy is a Go program, so it mean...

Tính hash cho hostname trong SSH known_hosts

SSH known host là gì SSH client lưu trữ danh sách các host key của tất cả các host mà người dùng đã truy cập (ssh vào) trong ~/.ssh/known_hosts để kiểm tra giá trị này vào lần SSH sau (ngoại lệ xem cuối bài). ~/.ssh/known_hosts Contains a list of host keys for all hosts the user has logged into that are not already in the systemwide list of known host keys. Ví dụ 2 dòng trong file known_hosts: github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz Mỗi dòng có định dạng: tên host đã dùng khi kết nối, loại key, và dạng base64 của public host key của host được ssh vào, ngoài ra có thể có commen...

Đọc code Python xem Ansible group priority thay đổi thứ tự gộp group vars

Ansible group dùng để nhóm các máy lại thành từng nhóm trong kho inventory. Khi một máy nằm trong nhiều group, các group vars sẽ được gộp lại, theo thứ tự children sẽ ghi đè parent, group sau sẽ ghi đè group trước . Sau và trước mặc định dựa theo tên group theo thứ tự bảng chữ cái. Trong Ansible inventory có thể cấu hình group priority cho group, khi không set có giá trị mặc định là 1 , giá trị priority có kiểu int, có thể là số âm. # lib/ansible/inventory/group.py class Group: """A group of ansible hosts.""" def __init__(self, name: str) -> None: name = helpers.remove_trust(name) self.depth: int = 0 self.name: str = to_safe_group_name(name) self.hosts: list[Host] = [] self._hosts: set[str] | None = None self.vars: dict[str, t.Any] = {} self.child_groups: list[Group] = [] self.parent_groups: list[Group] = [] self._hosts_cache: list[Host] | None = None self.pri...

Thẻ HTML link rel=alternate

Trong HTML, thẻ <link> thường dùng để liên kết các file file CSS hay favicon: <link rel="stylesheet" type="text/css" href="./theme/css/custom.css" media="screen"> <link rel="icon" href="favicon.ico" /> The <link> HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link Ngoài hai giá trị rel (relation) stylesheet , icon nói trên, còn nhiều giá trị khác, trong đó đáng chú ý là alternate The rel attribute defines the relationship between a linked resource and the current document Alternate representations of the current document. rel="alternate" dùng để liên kế...

Ansible không ưu tiên CLI option --user cao bằng inventory

99% các chương trình có giao diện dòng lệnh CLI đều ưu tiên option được người dùng chỉ định mức ưu tiên cao nhất. Ansible đặc biệt, vì nó nằm trong 1% còn lại. Mặc định, ansible sử dụng user của người dùng gõ lệnh $USER để ssh vào máy cần quản lý. Người dùng có thể thay đổi giá trị này với option --user REMOTE_USER . Nhưng khi trong inventory có chỉ định ansible_user thì khác: all: hosts: vm1: ansible_host: 127.0.0.1 ansible_user: inventory_user Chạy: $ ansible-playbook -i inventory.yml order.yml --user cli_user PLAY [all] ************************************************************************** TASK [Gathering Facts] ************************************************************** [ERROR]: Task failed: Failed to connect to the host via ssh: inventory_user@127.0.0.1: Permission denied (publickey,password). fatal: [vm1]: UNREACHABLE! => {"changed": false, "msg": "Task failed: Failed to connect to the host via ssh: inventory_user@127....

Ansible role luôn chạy trước task

Ansible là công cụ tự động hóa "đơn giản", "dễ dùng". Trong một ansible play, có thể dùng tasks, hoặc roles, hoặc cả hai. Thứ tự chạy của chúng có chút bất ngờ . Thứ tự role và task khi trong cùng play Playbook order.yml - hosts: all tasks: - name: task1 debug: msg: "This is task1" roles: - role: pika Role pika: roles/pika/tasks/main.yml : - name: task in role debug: msg: this is task in a role Output: $ uvx --from 'ansible-core>2.19' ansible-playbook -K -i localhost, order.yml BECOME password: PLAY [all] ************************************************************************** ... TASK [pika : task in role] ********************************************************** ok: [localhost] => { "msg": "this is task in a role" } TASK [task1] ************************************************************************ ok: [localhost] => { "msg": "This is task1" ...

[Python] Tính toán IP trong mạng

Python từ 3.3 có sẵn thư viện ipaddress rất tiện lợi để tính toán IP trong mạng. Thư viện ipaddress $ podman run -it python:3.10-alpine ... Python 3.10.19 (main, Oct 9 2025, 22:43:20) [GCC 14.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ipaddress >>> print(ipaddress.__doc__) A fast, lightweight IPv4/IPv6 manipulation library in Python. This library is used to create/poke/manipulate IPv4 and IPv6 addresses and networks. >>> ipaddress. ipaddress.AddressValueError( ipaddress.IPv4Network( ipaddress.collapse_addresses( ipaddress.ip_network( ipaddress.IPV4LENGTH ipaddress.IPv6Address( ipaddress.functools ipaddress.summarize_address_range( ipaddress.IPV6LENGTH ipaddress.IPv6Interface( ipaddress.get_mixed_type_key( ipaddress.v4_int_to_packed( ipaddress.IPv4Address( ...

Popular posts from this blog

Tài liệu và hướng dẫn học Python

Để tiết kiệm thời gian, tốt nhất là đi học PyMI Updated: 130617 Sau đây là các tài liệu khuyên dùng: Vì nhiều lý do, nên học python2.7 tại thời điểm hiện tại (giờ là tháng 6/2013 - muốn biết tại sao thì tự tìm hiểu) python 3.5+ (giờ là tháng 2/2017) Chuẩn bị: 1. biết bật tắt máy 2. biết cài python 3. tập gõ 10 ngón - gõ 2 ngón hay 1 ngón cũng không sao, nhưng 10 ngón là cách dễ nhất để gõ nhanh nhất. Tài liệu - Nên dùng tài liệu tại trang chủ của Python làm chính, tham khảo thêm các tài liệu khác tại http://www.familug.org/2016/12/free-ebook.html Căn bản, mới học 1.1 Python PyMI.vn https://pymi.vn/tutorial/ 1.2. Python offical tutorial kết hợp làm bài tập trên HackerRank  (đề bài bằng tiếng Anh, nhưng Google translate 1 lúc cũng ra vì có nhiều ví dụ mẫu đi kèm). Học viên của Pymi.vn có rất nhiều học viên đã tự học với Learn Python the hard way nhưng chưa thấy ai thành công cả. Hai link dưới nên đọc sau khi đã nắm được những phần cơ bản của ngôn ngữ pytho...

The PyMiers

New FAMILUG