websoft9/apps/roles/os/tasks/image.yml
chendelin1982 6ef98dd4eb os suport
2022-11-16 08:34:24 +08:00

62 lines
1.5 KiB
YAML

- name: Is cloud-init exists
shell: ls /etc/cloud/cloud.cfg
ignore_errors: True
register: result
- debug: var=result.stdout
- name: Install cloud-init
shell: |
yum install cloud-init
when: result.stdout != '/etc/cloud/cloud.cfg'
- name: Configure cloud-init
template:
src: cloud-init.cfg.j2
dest: /etc/cloud/cloud.cfg
- name: Configure time zone and delete useful cloud.conf
shell: |
timedatectl set-ntp yes
timedatectl set-timezone "Asia/Shanghai"
timedatectl set-local-rtc yes
rm -rf /etc/cloud/cloud.cfg.d/10_updates_policy.cfg
rm -rf /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg
- name: Change PasswordAuthentication
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "PasswordAuthentication no"
line: "PasswordAuthentication yes"
- name: Set enable login by root
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "#PermitRootLogin yes"
line: "PermitRootLogin yes"
- name: Restart sshd
shell: systemctl restart sshd
- name: Uninstall waagent
shell: |
yum -y remove WALinuxAgent
rm -f /etc/waagent.conf.rpmsave
rm -rf /var/lib/waagent
rm -f /var/log/waagent.log
when: ansible_os_family == "RedHat"
- name: Uninstall waagent
shell: |
apt -y purge walinuxagent
rm -rf /var/lib/waagent
rm -f /var/log/waagent.log
when: ansible_os_family == "Debian"
- name: Disable firewalld
shell: |
systemctl stop firewalld
systemctl disable firewalld
- include: "migration/{{os_cloudplatform}}.yml"