# setup & apt - module 5 :::info 跨 Linux distribution 安裝 git 程式 - Centos 透過 yum 安裝 - Ubuntu 透過 apt 安裝 ::: ### apt module - name - A package name - state <font color=red>**安裝現在的版本, 若非最 近的版本最新版則更新版本**</font> - latest <font color=red>**刪除**</font> - absent 刪除 <font color=red>**安裝現在的版本**</font> - present <font color=red>**ensures the package build dependencies are installed**</font> - build-dep ``` yaml - name: test apt yum hosts: all # inventory中的名稱 gather_facts: true become: yes tasks: - name: Test yum module # 用於Centos yum: name: git state: present when: ansible_facts['distribution'] == "CentOS" - name: Test apt module # 用於Ubuntu apt: name: git state: present when: ansible_facts["distribution"] == "Ubuntu" - name: unintall git apt: name: git state: absent when: ansible_facts["distribution"] == "Ubuntu" # 添加apt 倉庫 - name: install repositories become: true apt_repository: repo: ppa:deadsnakes/ppa update_cache: true when: ansible_facts["distribution"] == "Ubuntu" - name: install Python system packages become: true apt: name: - python3.6 - python3.6-dev - python-setuptools - python3-pip # 須另外安裝虛擬環境 - python3.4-venv state: present force_apt_get: yes when: ansible_facts["distribution"] == "Ubuntu" ``` ### 存到文件 ###### tags: `Ansible module`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up