-
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.
[IF-854] Add support to create Ansible playbook components (#48)
Co-authored-by: sternik <[email protected]>
- Loading branch information
Showing
7 changed files
with
178 additions
and
40 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
85 changes: 80 additions & 5 deletions
85
examples/resources/imagefactory_custom_component/resource.tf
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,19 +1,94 @@ | ||
// Copyright 2021 Nordcloud Oy or its affiliates. All Rights Reserved. | ||
// Copyright 2021-2023 Nordcloud Oy or its affiliates. All Rights Reserved. | ||
|
||
resource "imagefactory_custom_component" "component" { | ||
# An example of a SHELL component | ||
|
||
resource "imagefactory_custom_component" "shell_component" { | ||
name = "Install nginx" | ||
description = "Install nginx on Ubuntu" | ||
stage = "BUILD" | ||
cloud_providers = ["AWS", "AZURE"] | ||
os_types = ["LINUX"] | ||
content { | ||
script = <<-EOT | ||
script = <<-EOT | ||
apt-get update && apt-get install nginx -y | ||
EOT | ||
provisioner = "SHELL" | ||
} | ||
} | ||
|
||
output "component" { | ||
value = imagefactory_custom_component.component | ||
output "shell_component" { | ||
value = imagefactory_custom_component.shell_component | ||
} | ||
|
||
# An example of a Powershell component | ||
|
||
resource "imagefactory_custom_component" "powershell_component" { | ||
name = "Install Apache" | ||
description = "Install Apache HTTP Server on Microsoft Windows" | ||
stage = "BUILD" | ||
cloud_providers = ["AWS", "AZURE"] | ||
os_types = ["WINDOWS"] | ||
content { | ||
script = <<-EOT | ||
--- | ||
- name: Installing Apache HTTP Server | ||
hosts: all | ||
tasks: | ||
- name: Create directory structure | ||
ansible.windows.win_file: | ||
path: C:\ansible_examples | ||
state: directory | ||
- name: Download the Apache installer | ||
win_get_url: | ||
url: https://archive.apache.org/dist/httpd/binaries/win32/httpd-2.2.25-win32-x86-no_ssl.msi | ||
dest: C:\ansible_examples\httpd-2.2.25-win32-x86-no_ssl.msi | ||
- name: Install MSI | ||
win_package: | ||
path: C:\ansible_examples\httpd-2.2.25-win32-x86-no_ssl.msi | ||
state: present | ||
EOT | ||
provisioner = "POWERSHELL" | ||
} | ||
} | ||
|
||
output "powershell_component" { | ||
value = imagefactory_custom_component.powershell_component | ||
} | ||
|
||
# An example of a Ansible playbook component | ||
|
||
resource "imagefactory_custom_component" "ansible_component" { | ||
name = "Install nginx" | ||
description = "Install nginx using ansible playbook" | ||
stage = "BUILD" | ||
cloud_providers = ["AWS", "AZURE"] | ||
os_types = ["LINUX"] | ||
content { | ||
script = <<-EOT | ||
--- | ||
# playbook.yml | ||
- name: set up webserver | ||
hosts: all | ||
tasks: | ||
- name: ensure nginx is at the latest version | ||
package: | ||
name: nginx | ||
state: present | ||
- name: start nginx | ||
service: | ||
name: nginx | ||
state: started | ||
enabled: yes | ||
EOT | ||
provisioner = "ANSIBLE" | ||
} | ||
} | ||
|
||
output "ansible_component" { | ||
value = imagefactory_custom_component.ansible_component | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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