ansible-examples
ansible 範例
開發方式
- vagrant
vagrant 安裝
- vagrant
安裝完成後可能需要重新開機
以下為安裝方式
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
# sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant
vagrant version
- plugin
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-mutate
vagrant plugin install sahara
- ansible-lint
https://github.com/ansible-community/ansible-lint
sudo apt install ansible-lint
ansible-lint --version
vagrant 相關使用
- 新增 box
vagrant box add bento/debian-8.6 https://atlas.hashicorp.com/bento/boxes/debian-8.6
- 檢查一下目前所有安裝在本機的 Vagrant boxes
vagrant box list
- 移除不再需要的 box
vagrant box remove bento/debian-8.6
- 確認當前 Vagrant 主機的運作狀況
vagrant status
- 登入主機
vagrant ssh
- 列出主機的相關資訊
vagrant ssh-config
Host centOS6
HostName 192.168.121.2
User vagrant
Port 22
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/jameschang/Documents/vagrant/workspace/.vagrant/machines/centOS6/libvirt/private_key
IdentitiesOnly yes
LogLevel FATAL
- 休眠
vagrant spend
- 關機
vagrant halt
- 刪除
vagrant destroy --force
Vagrantfile
- 指定主機名稱
config.vm.define "serverName"
vagrant 常見問題
- This command requires a specific VM name to target in a multi-VM environment.
vagrant ssh debian10
學習相關資源
在地端建置Angular+ASP.NET Core的DevOps環境
30 天入門 Ansible 及 Jenkins [2018]
- Vagrant
- Ansible
怎麼安裝 Ansible (https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-debian)
- Playbook
- role