💻
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
Powered by GitBook
On this page
  • 1. Ansible Collections Nedir, Ne İşe Yarar?
  • 2. Koleksiyonların Faydaları
  • 3. Örnek Kullanım: Network Cihazları (Cisco, Juniper, vs.)
  • 4. Koleksiyon Nasıl Kurulur ve Kullanılır?
  • 5. Kendi Koleksiyonunuzu Oluşturmak
  • 1. Collection’ı Kurmak
  • 2. Basit Playbook Örneği
  • 3. Kısa Özet

Was this helpful?

  1. Ansible

Ansible Collections

1. Ansible Collections Nedir, Ne İşe Yarar?

Ansible “Collection” (koleksiyon), modüller, roller, eklentiler (plugins) ve ilişkili diğer öğelerin tek bir paket (self-contained) halinde dağıtılmasını sağlayan bir yapı sunar.

  • Örnek: “network.cisco” adında bir koleksiyon, Cisco cihazlarını yönetmek için özel modüller, roller vb. içerebilir.

  • Kısacası, “Bir pakette vendor’a/belirli bir amaca özel tüm Ansible içeriklerini toplamak ve paylaşmak” demektir.

Neden Gerekli?

  • Ansible’ın kendi çekirdek modülleri her durumda yeterli olmayabilir (özelleşmiş vendor veya bulut API’lerine ihtiyaç duyabilirsiniz).

  • Collections, topluluk veya vendor tarafından yazılmış gelişmiş/özel fonksiyonları kolayca yükleyip kullanmanızı sağlar.

2. Koleksiyonların Faydaları

  1. Genişletilmiş Fonksiyonellik

    • Örneğin, bulut sağlayıcı (AWS, Azure) veya network vendor (Cisco, Juniper) modülleri, Ansible core’da sınırlı olabilir.

    • Bir koleksiyon yükleyerek, “cloud.xyz” veya “network.abc” adıyla ekstra modüllere/rollere erişirsiniz.

  2. Modülerlik ve Tekrar Kullanım

    • Koleksiyonlar, “rol”, “modül” ve “plugin” gibi parçaları bir arada paketler.

    • Böylece bir projede kullanırken, başka projede de aynı koleksiyonu ekleyip tekrar kullanabilirsiniz.

  3. Dağıtım ve Versiyon Yönetimi

    • “requirements.yml” dosyasında hangi koleksiyonların hangi sürümlerini istediğinizi tanımlayabilir, tek komutla hepsini kurabilirsiniz.

    • Bu, sürüm çakışmalarını veya yanlış modül sürümü gibi hataları önler.

3. Örnek Kullanım: Network Cihazları (Cisco, Juniper, vs.)

  1. Senaryo: Büyük bir ağ altyapısında Cisco, Juniper, Arista cihazlarını yönetmek istiyorsunuz.

  2. Varsayılan Ansible network modülleri yetmeyebilir.

  3. Her vendor’ın “network.cisco”, “network.juniper” benzeri koleksiyonları olabilir.

  4. Koleksiyonu yükleyerek (örn. ansible-galaxy collection install network.cisco), vendor’a özgü modülleri elde edersiniz.

  5. Artık network.cisco koleksiyonu içindeki modülleri playbook’larınızda doğrudan çağırabilirsiniz (örn. “cisco_ios_config” gibi).

4. Koleksiyon Nasıl Kurulur ve Kullanılır?

4.1 Basit Kurulum

ansible-galaxy collection install network.cisco

Bu komut, network.cisco koleksiyonunu indirip sisteminizdeki koleksiyon dizininde (örn. ~/.ansible/collections/) saklar.

4.2 Playbook’ta Kullanmak

- name: Configure Cisco
  hosts: cisco-devices
  collections:
    - network.cisco
  tasks:
    - name: Example Cisco command
      cisco.ios.ios_config:  # buradaki "cisco.ios.ios_config" modülü koleksiyon içinden gelir
        lines:
          - hostname Router1

collections: altında “network.cisco” belirterek bu koleksiyondaki modülleri (ör. cisco.ios.ios_config) kullanabilirsiniz.

4.3 requirements.yml ile Versiyon Belirtmek

collections:
  - name: network.cisco
    version: "2.1.0"
  - name: amazon.aws
    version: "3.5.0"
  • Sonra:

    ansible-galaxy collection install -r requirements.yml
  • Tüm koleksiyonlar istenen sürümlerde kurulur.

5. Kendi Koleksiyonunuzu Oluşturmak

  • İhtiyaç duyduğunuz modüller, roller veya plugin’ler varsa kendi namespace altında bir koleksiyon oluşturabilirsiniz (örn. “my_namespace.my_collection”).

  • Bu koleksiyonu ansible-galaxy collection init my_namespace.my_collection komutuyla başlatır, oluşturulan dizin yapısına kodlarınızı yerleştirir, sonra ister lokal projelerde kullanır ister Galaxy’de paylaşırsınız.

Colections Example,

Aşağıda basit bir Ansible collection kullanım örneği gösteriyorum. Bu örnekte, topluluk tarafından sağlanan “community.general” adlı koleksiyonu kullanıp bir görevi yerine getireceğiz. “community.general” koleksiyonunda pek çok ek modül yer alır (örneğin, zamanla ilgili bir modül veya sistemle ilgili ekstra komutlar).


1. Collection’ı Kurmak

# Terminalden çalıştırın:
ansible-galaxy collection install community.general

Bu komut, community.general koleksiyonunu varsayılan koleksiyon dizinine indirir (ör. ~/.ansible/collections/ veya roles_path / collections_paths ayarlarınıza göre).


2. Basit Playbook Örneği

Aşağıda örnek bir playbook var; bu playbook’ta community.general koleksiyonu içindeki bir modülü (örnek olarak community.general.shell gibi) kullanacağız.

# file: playbook.yml
- name: Demo of using community.general collection
  hosts: localhost
  collections:
    - community.general    # <-- Koleksiyonu burada belirtiyoruz
  gather_facts: no
  tasks:
    - name: Example usage of a module from community.general
      # Örnek olarak 'community.general.shell' modülü 
      # (aslında builtin 'shell'e benzer, ama genişletilmiş fonksiyonellik sunabilir)
      community.general.shell: 
        cmd: "echo 'Hello from community.general!'"
        chdir: /tmp
      register: shell_output

    - name: Show output
      debug:
        var: shell_output.stdout
  1. collections: altında community.general yazdığımız için, bu playbook o koleksiyondaki modülleri arar ve kullanabilir.

  2. community.general.shell: satırında, koleksiyonun içindeki shell modülünü çağırıyoruz (örneğin, ek parametre veya gelişmiş seçenekler sunuyor olabilir).

  3. Komut çalıştırıldıktan sonra sonucu shell_output’a kaydedip (register: shell_output), sonrasında debug ile ekrana basıyoruz.

Nasıl Çalıştırılır?

ansible-playbook playbook.yml

Çıktıda:

TASK [Example usage of a module from community.general] ************************
changed: [localhost]

TASK [Show output] **************************************************************
ok: [localhost] => {
    "shell_output.stdout": "Hello from community.general!"
}

Böylece community.general koleksiyonundan bir modülü doğrudan kullanmış olduk.


3. Kısa Özet

  1. Koleksiyonu Yükle: ansible-galaxy collection install <koleksiyon_ismi>

  2. Playbook’ta Belirt: collections: altında <namespace>.<collection_name> ifadesini ekleyin.

  3. Modülü Kullanın: <namespace>.<collection_name>.<modül> şeklinde çağırabilirsiniz (veya eğer collections: satırında belirttinizse, doğrudan collection_name.modul ismi de çalışır).

Bu şekilde, koleksiyonlardaki ek modüller, roller ve plugin’lerden kolayca yararlanabilirsiniz.

PreviousAnsible RolesNextIntroduction to Templating

Last updated 3 days ago

Was this helpful?

LogoCollection Index — Ansible Community Documentation