💻
Cheet Sheets
  • 🦁Başlarken
  • 🟧DevOps Pre-Requisite
    • ❤️Why Linux? | Linux Basics #1
    • 💛Vi Editor | Linux Basics #2
    • 💙Basics Commands | Linux Basics #3
    • 🧡Package Managers | Linux Basics #4
    • 💚Services | Linux Basics #5
    • 💛Networking Basics
    • 🤎DNS Basics
    • 🩶Applications Basics
    • 🟨Java introduction
    • 🟩NodeJS Introduction
    • 🟦Python Introduction
    • 🟪GIT Introduction
    • 🟧Apache Web Server Introduction
    • ⬛Apache Tomcat
    • 🟫Python Flask
    • 🟥Node.js Express App
    • 🟨Databases
    • 🟩MySQL
    • 🟪MongoDB
    • 🟨SSL & TLS
    • 🟦YAML & JSON - JSON Path
    • ⬛Labs Resources
  • 🍎Kubernetes
    • 🍏Kubernetes: Nedir ?
    • 🍒Bileşenler
    • 🍵Kubectl ve Versiyon
    • ❤️Pod
    • 🏷️Label ve Selector
    • 🔎Annotation
    • 📲Namespaces
    • 📦Deployments
    • 🔁ReplicaSet
    • 🔙Rollout & Rollback
    • 🌐Networking - 1
    • 🌏Service
    • 🛠️Liveness Probe & Readiness Probe
    • 🥐Resource Limits
    • 💰Environment Variables
    • 📃Ephemeral Volumes
    • 🔑Secrets
    • 🌂ConfigMap
    • 🖥️Node Affinity
    • 🔌Pod Affinity
    • ✍️Taint and Toleration
    • 🔦DaemonSet
    • 🧀PV/PVC
    • 🌜Storage Class
    • 🗿StatefulSet
    • 🕹️Job & Cronjob
    • 🔐Authentication
    • 📏Role-based access control (RBAC)
    • 🈷️Service Account
    • 📈Ingress
    • 📂ImagePullPolicy & ImageSecret
    • 📖Static Pods
    • 🌐Network Policy
    • 🫐Helm Nedir?
    • 📽️Prometheus Stack - Monitoring
    • 💼EFK Stack - Monitoring
    • 🥳CRD & Operator
  • 🧑‍⚕️GIT & GITHUB
    • 👉Girizgah
    • 🌴Branch
    • 🤝Merge
    • 🤔Conflict - Rebase
    • 🇸🇴Alias
    • 🛑Gitignore
    • 🥢Diff
    • ◀️Checkout
    • 🔦Stash
    • 👉Other
  • ☁️AWS
    • 🪣S3
    • 🚙EC2
    • ⚖️ELB
    • 🤝Auto Scaling
    • 🗄️EFS
    • 🔐VPC
    • 🎆CloudFront
    • ❤️Route53
    • 🦈RDS
    • 🏢ElastiCache
    • 🔭CloudWatch
    • 👀CloudTrail
    • 📃CloudFormation
    • 🔕SNS
    • 📬SQS
    • 🎇SWF
    • 📧SES
    • 📦Kinesis
    • 📐AWSConfig
    • 👩‍🏭OpsWork
    • 🚀Lambda - Api Gateway
    • 📌ECS - EKS
    • 🔑KMS
    • 📂Directory Service
    • 🏐Snowball
    • 💾Storage Gateway
    • 💽Volume Gateway
    • 📼Tape Gateway
    • 🏠Organizations
    • 🔙Backup-Transfer-CloudShell
    • 🆔IAM
    • 📀DataSync
    • 🗃️FSx
    • 🎒Aurora Serverless
    • 🌐Global Accelerator
    • 💪HPC
    • 🎰Outposts
    • 🗼Others
  • 👨‍🔬Ansible
    • 👉Girizhah
    • 📔YAML
    • ⚙️Komponentler
    • 🎒Inventory
    • 🏑ad-hoc
    • ▶️Playbook
  • 👨‍⚕️PROMETHEUS
    • 📈Terminoloji
    • 🦯Ubuntu 20.04 Prometheus Kurulum
    • 🗒️prometheus.yml dosyasına ilk bakış:
    • 🧭promQL up query
    • 📇Exporters
    • 🔦promQL Data Types
    • 🦯Selectors & Matchers
    • 🔢Binary Operators
    • 💀ignoring and on
    • ✍️Aggregation Operators
    • 🧠Functions
    • 🖊️Alıştırma
    • 💻Client Libraries
    • 🐍Examining the data of our Python application
    • 🐐Examining the data of our GO application
    • ⏺️Recording Rules
    • 💡rate functions
    • ⏰Alerting
    • ⌚Alert Routing
    • ⏰Slack integration with Prometheus
    • 🤯PagerDuty integration with Prometheus
    • ◼️BlackBox exporter
    • 📍Push Gateway
    • 🪒Service Discovery
    • 🧊kube cadvisor with external prometheus
    • 👉aws with prometheus
    • ☁️CloudWatch Exporter
    • 👨‍🚒mysql exporter
    • 🛃Custom exporter with Python
    • ⚙️Prometheus with HTTP API
    • 🤖Prometheus Federation For Kubernetes
    • 📺Grafana
    • ⁉️Prometheus: Ne zaman kullanılmalı? Ne zaman kullanılmamalıdır?
  • 🍪Sheets
    • 🛳️Docker Sheets
    • 🐐Kube Sheets
  • 🔢12 Factor APP
    • 🏗️Introduction
    • 1️⃣Codebase
    • 2️⃣Dependencies
    • 3️⃣Concurrency
    • 4️⃣Processes
    • 5️⃣Backing Services
    • 6️⃣Config
    • 7️⃣Build, release, run
    • 8️⃣Port binding
    • 9️⃣Disposability
    • 🔟Dev/prod parity
    • 🕚Logs
    • 🕛Admin processes
  • ☁️Azure 104
    • 👨‍👨‍👧‍👧Azure Active Directory ( Entra ID )
    • 💰Subscriptions
    • 🌎Virtual Network (VNET)
    • 💻Virtual Machines
    • 🧑‍🌾Load Balancing
    • 🥍Network Advanced
    • 🪡Automating Deployment and Configuration
    • 💂Securing Storage
    • 📓Administering Azure Blobs and Azure Files
    • 🔧Managing Storage
    • 🎁App Service
    • 🛳️Azure Container
    • 🥇Backup And Recovery
    • 🪐Network Watcher
    • ⏰Resource Monitoring And Alerts
  • ⛅AZURE 305
    • 🆔identity and access management
    • 💼Desing Azure AD (Entra ID)
    • 👨‍💼Desing for Azure B2B
    • 🛃Desing for Azure B2C
    • 💳Design for MFA and Conditional Access
    • ⛑️Design for Identity Protection
    • 🚶Access Reviews
    • 🚦Managed identity Demostration
    • 🔐Key Vault Demostration
    • 👑Governance hierarchy
    • 💠Design for Management Groups
    • 🔑Desing for Subscriptions
    • 🍇Desing for resource groups
    • 📟Design for resource tags
    • 🚷Azure Policy & RBAC
    • 🫐Desing For Blueprints
    • 🪡Desing for Virtual Networks
    • 🛫Design for on-premises connectivity to Azure
    • 🔽Design for network connectivity
    • 📦Design for application delivery
    • 🥞Design for network security and application protection
    • 📕Choose a compute solution
    • 🌊Design for virtual machines
    • 🔋Azure Batch Demostration
    • 🛰️Design for Azure App Service
    • ⛲Design for Azure Container Instances
    • 🎢Design for Azure Kubernetes Service
    • 📠Azure Functions Demostration
    • 💪Azure Logic Apps Demostration
    • 🧑‍💼Design for data storage
    • 🎞️Design for Azure storage accounts
    • 🌟Choose the storage replication
    • 📹Azure blob storage - Lifecycle & immutable demo
    • 🥌Azure Files Demostration
    • 🕸️Design Azure disks
    • 🦼Design for storage security
    • 🔮Azure Table Storage And Cosmos DB Demostration
    • 🟧Azure SQL Solutions
    • 🎡Azure SQL Database - Purchasing models
    • 🕯️Database availability
    • 📜Data security strategy
    • 🧮Azure SQL Edge
    • 🚲Azure Data Factory
    • 🔅Azure Data Lake Storage
    • 🧘‍♂️Azure Databricks
    • 🎒Azure Synapse Analytics
    • 🅰️Azure Stream Analytics
    • 📼Data flow strategy
    • 🍥Cloud Adoption Framework
    • ☣️Azure Migration Framework
    • 🦿Assessing workloads
    • 🪡Migration tools
    • 🤖Azure Database migration
    • 👥Storage migration
    • 👜Azure Backup
    • ⏲️Azure Blob Backup and Recovery
    • 💈Azure files backup and recovery
    • 🎞️Azure VM backup and recovery
    • 🧺Azure SQL backup and recovery
    • ⏰Azure Site Recovery
    • 📩Differentiate event and message
    • ✈️Azure messaging solutions
    • 🚜Event Hub
    • 🥍Application optimization solution
    • 🎁Application lifecycle
    • 📺Azure Monitor
    • 🅱️Log Analytics
    • 👥Azure workbooks and Insights
    • 🚌Azure Data Explorer
  • Github Actions
    • Github Actions Nedir?
    • Workflow & Schedule Triggers
    • Single and Multiple Events
    • Manuel Events
    • Webhook Events
    • Conditional Keywords For Steps
    • Expressions - 1
    • Expressions - 2
    • Runners
    • Workflow Commands
    • Workflow Context
    • Dependent Jobs
    • Encrypted Secrets
    • Configuration Variables
    • Default & Custom Env Varb
    • Set Env Varb with Workflow Commands
    • Github Token Secret
    • Add Script to workflow
    • Push Package #1
    • Push Package #2 Docker
    • Service Containers
    • Routing workflow to runner
    • CodeQL Step
    • Caching Package and Dependency Files
    • Remove workflow Artifact
    • Workflow Status Badge
    • Env Protection
    • Job Matrix Configuration
    • Disable & Delete Workflows
    • Actions type for Action
    • Inputs and Outputs for actions
    • Action Versions
    • Files and Directories for Actions
    • Exit Codes
    • Reusable Workflow & Reuse Templates for Actions and Workflows
    • Configure Self Hosted Runners for Enterprise
  • Loki
    • What is Loki?
    • Architecture of Loki
    • Install Loki For Ubuntu
    • Install Promtail For Ubuntu
    • Querying Logs
    • Loki in Kubernetes
    • Deploying Loki in Kubernetes
    • Connecting to Grafana
    • Viewing Kubernetes logs
    • Promtail Customize & Pipeline
  • Ansible
    • Ansible Introduction
    • Introduction to Ansible Configuration Files
    • Ansible Inventory
    • Inventory Formats
    • Ansible Variables
    • Variable Types
    • Registering Variables and Variable Precedence
    • Variable Scoping
    • Magic Variables
    • Ansible Facts
    • Ansible Playbooks
    • Verifying Playbooks
    • Ansible lint
    • Ansible Conditionals
    • Ansible Conditionals based on facts, variables, re-use
    • Ansible Loops
    • Ansible Modules
    • Introduction to Ansible Plugins
    • Modules and Plugins Index
    • Introduction to Handlers
    • Ansible Roles
    • Ansible Collections
    • Introduction to Templating
    • Jinja2 Templates for Dynamic Configs
  • 🅰️Ansible Advanced
    • Playbook run options
    • Facts
    • Configuration files
    • Install required packages
    • SSH keys to managed nodes
    • Adhoc Commands
    • Commands with shell scripts
    • Privilege Escalation
    • Frequently Asked Questions
    • Additional Modules
    • Variable Precedence
    • Variable Scope
    • Use variables to retrieve the results of running commands
    • Magic Variables
    • Jinja2 Basics
    • Jinja2 in Ansible
    • Templating use cases
Powered by GitBook
On this page
  • 1. Varsayılan Ansible Konfigürasyon Dosyası
  • 2. Konfigürasyon Dosyası Öncelik Sırası
  • 3. Konfigürasyon Dosyalarını ve Değerlerini Değiştirme Yöntemleri

Was this helpful?

  1. Ansible

Introduction to Ansible Configuration Files

1. Varsayılan Ansible Konfigürasyon Dosyası

  • Kurulum Sonrası Varsayılan Dosya Ansible kurulunca, genellikle /etc/ansible/ansible.cfg konumunda bir varsayılan konfigürasyon dosyası oluşturulur.

  • Bölümler (Sections) Bu dosya çeşitli bölümlere sahiptir (örn: [defaults], [inventory], [privilege_escalation], [ssh_connection], vb.).

    • En çok ayar genellikle [defaults] bölümünde yer alır.

    • Örnek ayarlar:

      • Varsayılan envanter dosyası (inventory) konumu

      • Log dosyası konumu

      • Modül veya rol dizinleri

      • SSH bağlantı zaman aşımı (timeout) süresi

      • Ansible’ın “facts” (sistem bilgileri) toplayıp toplamayacağı

      • Aynı anda kaç host’u paralel işleyebileceği (forks)

Bu varsayılan dosya, herhangi bir ek ayar belirtilmezse Ansible tarafından her zaman okunur.

2. Konfigürasyon Dosyası Öncelik Sırası

Ansible, birden fazla konfigürasyon dosyası bulunursa belli bir öncelik sırasına göre ayarları okur. Yani, Ansible, ayarları (konfigürasyonları) birden fazla yerden okuyabilir. Ama aynı ayar farklı dosyalarda farklı değerlerle tanımlanırsa, en yüksek öncelikli olan kazanır. İşte öncelik sırası (en yüksek → en düşük):

  1. Environment Variable

    • ANSIBLE_CONFIG adında bir değişken, konfigürasyon dosyasının tam yolunu gösterir.

    • Örneğin,

      export ANSIBLE_CONFIG=/opt/ansible-web.cfg
    • Bu şekilde ayarlanırsa, ilk olarak buradaki ayarlar kullanılır.

  2. Mevcut Çalışma Dizini (Current Directory)

    • Ansible komutunu çalıştırdığın dizinde bir ansible.cfg dosyası varsa, ikinci olarak buradaki ayarlar geçerli olur.

  3. Kullanıcının Ev Dizini (Home Directory) İçindeki .ansible.cfg

    • Örneğin, /home/onur/.ansible.cfg dosyası.

    • Eğer çevre değişkeni veya çalışma dizininde bir dosya yoksa, üçüncü sırada bu dosyayı kontrol eder.

  4. Varsayılan Sistem Dosyası

    • /etc/ansible/ansible.cfg

    • Hiçbir üstteki konfigürasyon yoksa veya ilgili ayar oralarda belirtilmemişse, en son bu dosyanın değerleri kullanılır.

Nasıl Düşünmeliyiz?

  • Eğer tek bir ayarı herkesten önce zorla değiştirmek istiyorsan → Environment Variable ile ANSIBLE_CONFIGkullan.

  • Bulunduğun dizinde özel ayarlar istiyorsan → ansible.cfg dosyasını oraya koy.

  • Tüm kullanıcılar için geçerli varsayılan bir ayar yapmak istiyorsan → /etc/ansible/ansible.cfg dosyasını düzenle.

Örnek Senaryo:

  • /etc/ansible/ansible.cfg içinde timeout=10 yazıyor.

  • Kendi klasöründeki ansible.cfg içinde timeout=20 yazarsan, senin klasöründe Ansible çalıştırıldığında 20 geçerli olur.

  • Ayrıca export ANSIBLE_CONFIG=/home/onur/diger_ayarlar.cfg yapıp o dosyada timeout=30 yazarsan, bu kez 30 geçerli olur.

Bu şekilde, Ansible hangi dosyanın ayarını seçeceğini belirli bir öncelik sırasına göre karar verir.

3. Konfigürasyon Dosyalarını ve Değerlerini Değiştirme Yöntemleri

Ansible Konfigürasyonunu Değiştirmek İçin Üç Ana Yol Var:

  1. Klasöre (Dizine) ansible.cfg Dosyası Kopyalamak

    • Eğer /etc/ansible/ansible.cfg dosyası var ve bu dosyadaki ayarları biraz değiştirmek istiyorsan:

      1. Projende, örneğin web-playbooks klasörüne geç.

      2. Orada ansible.cfg adında yeni bir dosya oluştur (veya /etc/ansible/ansible.cfg’den kopyala).

      3. İçindeki sadece değiştirmek istediğin satırları düzenle (örn. timeout=20).

    • Artık o klasörde ansible-playbook ... komutunu çalıştırdığında, o klasördeki ansible.cfg ayarları geçerli olur.

  2. Environment Variable (Değişken) Kullanmak

    • Eğer tek bir ayarı hızlıca değiştirmek istiyorsan, ansible.cfg dosyasıyla uğraşmadan terminalde şu şekilde yazabilirsin:

      ANSIBLE_GATHERING=explicit ansible-playbook myplaybook.yml

      Bu komut çalışırken ANSIBLE_GATHERING değeri geçici olarak explicit olur ve diğer tüm dosyalardaki gathering ayarlarını yok sayar.

    • Ya da önce değişkeni kalıcı yapmak istersen,

      export ANSIBLE_GATHERING=explicit
      ansible-playbook myplaybook.yml

      şeklinde iki satırda yazabilirsin. Bu sayede, o terminal oturumu boyunca (exit yapana kadar) gathering ayarı explicit kalır.

  3. Sadece Birkaç Ayar Değiştirmek İstediğinde

    • Bazen tüm ansible.cfg dosyasını kopyalayıp düzenlemek yerine, yalnızca 1-2 küçük ayar değiştirmen gerekebilir.

    • Bu durumda, environment variable yöntemi çok pratiktir. Tek bir ayarı override (geçersiz kıl) etmek için:

      ANSIBLE_GATHERING=explicit ansible-playbook myplaybook.yml
    • Böylece sistemde başka yerde hangi ayar varsa varsın, bu tek komutluk değişken her şeyin önüne geçer.

Kısa Özet

  • Klasöre ansible.cfg kopyalamak: Proje/klasör bazında kalıcı ayarlar yapmak istediğinde kullanılır.

  • Environment variable: Hızlı veya tek seferlik ayar değişikliği için idealdir.

ANSIBLE_GATHERING sadece bir örnek. Ansible’ın konfigürasyon dosyasında yer alan hemen hemen her parametre, aynı mantıkla bir çevresel değişken (environment variable) olarak geçersiz kılınabilir. Yani ANSIBLE_GATHERING=explicit yerine başka bir ayarı da ANSIBLE_XXX=... şeklinde değiştirebilirsin. Ansible’da bir konfigürasyon parametresini çevresel değişken aracılığıyla değiştirmek istiyorsan, genellikle şu kural geçerlidir:

  1. Önce ilgili parametrenin adını büyük harflere çevir.

  2. Başına ANSIBLE_ önekini (prefix) ekle.

  3. Değerini atayıp komut çalıştır (veya export komutu kullan).

Örneğin, Ansible’ın ansible.cfg dosyasında şu parametrelerin olduğunu düşünelim:

  • gathering

  • forks

  • host_key_checking

  • timeout

Bunları çevresel değişken olarak atayabilmek için sırasıyla:

  • ANSIBLE_GATHERING=...

  • ANSIBLE_FORKS=...

  • ANSIBLE_HOST_KEY_CHECKING=...

  • ANSIBLE_TIMEOUT=...

şeklinde kullanman gerekir.

PreviousAnsible IntroductionNextAnsible Inventory

Last updated 1 month ago

Was this helpful?