-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from robsonsnt/feat/provisioner_ansible
Feat/provisioner ansible
- Loading branch information
Showing
14 changed files
with
564 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
# proxmox-packer | ||
# Proxmox Packer | ||
|
||
Este projeto é usado para criar imagens de máquinas virtuais (VMs) para o Proxmox usando o Packer. As imagens criadas são compatíveis com o cloud-init, o que permite que você configure VMs no momento da criação usando arquivos de configuração do cloud-init. | ||
|
||
## Pré-requisitos | ||
|
||
- [Packer](https://www.packer.io/downloads) | ||
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) | ||
- [Proxmox](https://www.proxmox.com/en/downloads) | ||
|
||
Antes de executar o Packer, você precisará configurar algumas variáveis no arquivo `variables.pkrvars.hcl`. Este arquivo contém várias variáveis que o Packer usa para criar a imagem. As variáveis que você precisa configurar incluem: | ||
|
||
- `proxmox_url`: O URL do seu servidor Proxmox. | ||
- `proxmox_user`: O nome de usuário para se conectar ao Proxmox. | ||
- `proxmox_password`: A senha para se conectar ao Proxmox. | ||
- `template_name`: O nome do template que será criado. | ||
|
||
|
||
## Como usar | ||
|
||
1. Clone este repositório para o seu local de trabalho. | ||
2. Navegue até o diretório do projeto. | ||
3. Execute o playbook Ansible para verificar e remover o template existente (se necessário): | ||
|
||
```bash | ||
ansible-playbook playbook.yml | ||
``` | ||
|
||
4. Execute o Packer para criar a nova imagem: | ||
|
||
```bash | ||
packer build packer.pkr.hcl | ||
``` | ||
|
||
5. No Proxmox, você pode agora criar uma nova VM usando a imagem criada. Durante a criação da VM, você pode fornecer um arquivo de configuração do cloud-init para configurar a VM. | ||
|
||
## Contribuindo | ||
|
||
Contribuições para este projeto são bem-vindas. Por favor, abra um problema ou uma solicitação de pull. | ||
|
||
## Licença | ||
|
||
Este projeto está licenciado sob a licença MIT. Veja o arquivo LICENSE para mais detalhes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[defaults] | ||
timeout = 60 | ||
gathering = smart | ||
inventory = ansible/inventory/ | ||
library = ansible/library | ||
roles_path = ansible/roles | ||
host_key_checking = False | ||
retry_files_enabled = False | ||
callback_whitelist = profile_tasks, timer | ||
deprecation_warnings = False | ||
|
||
[ssh_connection] | ||
pipelining = False | ||
ssh_args = -o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[defaults] | ||
timeout = 60 | ||
gathering = smart | ||
inventory = ansible/inventory/ | ||
library = ansible/library | ||
roles_path = ansible/roles | ||
host_key_checking = False | ||
retry_files_enabled = False | ||
callback_whitelist = profile_tasks, timer | ||
deprecation_warnings = False | ||
|
||
[ssh_connection] | ||
pipelining = False | ||
ssh_args = -o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[defaults] | ||
timeout = 60 | ||
gathering = smart | ||
inventory = ansible/inventory/ | ||
library = ansible/library | ||
roles_path = ansible/roles | ||
host_key_checking = False | ||
retry_files_enabled = False | ||
callback_whitelist = profile_tasks, timer | ||
deprecation_warnings = False | ||
|
||
[ssh_connection] | ||
pipelining = False | ||
ssh_args = -o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Base linux configuration for packer images | ||
hosts: linux | ||
become: true | ||
|
||
tasks: | ||
- name: Install base packages | ||
ansible.builtin.yum: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: | ||
- curl | ||
- wget | ||
- unzip | ||
- git | ||
- vim | ||
- net-tools | ||
- telnet | ||
|
||
# - name: System update | ||
# ansible.builtin.yum: | ||
# name: "*" | ||
# state: present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- name: Remove Template | ||
hosts: localhost | ||
connection: local | ||
tasks: | ||
- name: Get template informations | ||
community.general.proxmox_kvm: | ||
api_user: "{{ api_user }}" | ||
api_token_id: "{{ api_token_id }}" | ||
api_token_secret: "{{ api_token_secret }}" | ||
api_host: "{{ proxmox_host }}" | ||
vmid: "{{ vmid }}" | ||
node: "{{ proxmox_node }}" | ||
state: current | ||
register: vm_info | ||
ignore_errors: true | ||
|
||
- name: Remove template especific ID | ||
community.general.proxmox_kvm: | ||
api_user: "{{ api_user }}" | ||
api_token_id: "{{ api_token_id }}" | ||
api_token_secret: "{{ api_token_secret }}" | ||
api_host: "{{ proxmox_host }}" | ||
vmid: "{{ vmid }}" | ||
node: "{{ proxmox_node }}" | ||
state: absent | ||
when: vm_info.vmid is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
packer { | ||
required_plugins { | ||
proxmox = { | ||
version = ">= 1.1.8" | ||
source = "github.com/hashicorp/proxmox" | ||
} | ||
ansible = { | ||
version = ">= 1.1.1" | ||
source = "github.com/hashicorp/ansible" | ||
} | ||
} | ||
} |
Oops, something went wrong.