hitachienergy / epiphany

Cloud and on-premises automation for Kubernetes centered industrial grade solutions.
Apache License 2.0
139 stars 107 forks source link

[BUG] [Ubuntu] `firewalld.service` unit could not be found on host however ansible_facts sees it as defined #2940

Closed przemyslavic closed 2 years ago

przemyslavic commented 2 years ago

Describe the bug There are a few tasks in firewall role that should be executed only if ansible_facts.services['firewalld.service'] is defined https://github.com/epiphany-platform/epiphany/blob/develop/ansible/playbooks/roles/firewall/tasks/configure-firewall.yml#L154. However, on epicli re-run on Ubuntu, these tasks are being executed failing the build when trying to stop firewalld service which actually could not be found.

2022-02-02T11:09:22.0849853Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand - TASK [firewall : Print firewalld.service state] ********************************[0m
2022-02-02T11:09:22.1266620Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand - ok: [ec2-1-1-1-1.eu-west-1.compute.amazonaws.com] => {[0m
2022-02-02T11:09:22.1273463Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -     "ansible_facts.services['firewalld.service']": {[0m
2022-02-02T11:09:22.1277935Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -         "name": "firewalld.service",[0m
2022-02-02T11:09:22.1279357Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -         "source": "systemd",[0m
2022-02-02T11:09:22.1280280Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -         "state": "stopped",[0m
2022-02-02T11:09:22.1281183Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -         "status": "not-found"[0m
2022-02-02T11:09:22.1281988Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand -     }[0m
2022-02-02T11:09:22.1282699Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand - }[0m
2022-02-02T11:09:22.1409431Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand - [0m
2022-02-02T11:09:22.1410501Z [38;21m11:09:22 INFO cli.engine.ansible.AnsibleCommand - TASK [firewall : Stop and disable firewalld service] ***************************[0m
2022-02-02T11:09:23.4550719Z [31;21m11:09:23 ERROR cli.engine.ansible.AnsibleCommand - fatal: [ec2-1-1-1-1.eu-west-1.compute.amazonaws.com]: FAILED! => {"changed": false, "msg": "Could not find the requested service firewalld: host"}[0m
[ubuntu@ec2-1-1-1-1 ~]$ systemctl status firewalld
Unit firewalld.service could not be found.

This is related to Ansible/Python update #2933.

How to reproduce Steps to reproduce the behavior:

  1. Re-deploy any cluster. The repository vm should be sufficient to reproduce.

Expected behavior Re-apply command should succeed.

Config files

Environment

epicli version: [2.0.0dev]

Additional context Add any other context about the problem here.


DoD checklist

przemyslavic commented 2 years ago

to work around add this to your data yaml:

---
kind: configuration/feature-mapping
title: "Feature mapping to roles"
name: default
provider: aws
specification:
  available_roles:
    - _merge: true
    - name: firewall
      enabled: false
atsikham commented 2 years ago

The reason is Ansible upgrade with following changes: https://github.com/ansible/ansible/pull/75326/files

However I don't see that documentation has been updated 😞

Related commands output:

root@ec2-52-205-252-202:/home/ubuntu# systemctl daemon-reload
root@ec2-52-205-252-202:/home/ubuntu# systemctl list-units --no-pager --type service --all
  UNIT                                           LOAD      ACTIVE   SUB     DESCRIPTION                                                          
  accounts-daemon.service                        loaded    active   running Accounts Service                                                     
  acpid.service                                  loaded    active   running ACPI event daemon                                                    
  apparmor.service                               loaded    active   exited  Load AppArmor profiles                                               
  apport-autoreport.service                      loaded    inactive dead    Process error reports when automatic reporting is enabled            
  apport.service                                 loaded    active   exited  LSB: automatic crash report generation                               
  apt-daily-upgrade.service                      loaded    inactive dead    Daily apt upgrade and clean activities                               
  apt-daily.service                              loaded    inactive dead    Daily apt download activities                                        
  atd.service                                    loaded    active   running Deferred execution scheduler                                         
  auditd.service                                 loaded    active   running Security Auditing Service                                            
  blk-availability.service                       loaded    active   exited  Availability of block devices                                        
  cloud-config.service                           loaded    active   exited  Apply the settings specified in cloud-config                         
  cloud-final.service                            loaded    active   exited  Execute cloud user/final scripts                                     
  cloud-init-hotplugd.service                    loaded    inactive dead    cloud-init hotplug hook daemon                                       
  cloud-init-local.service                       loaded    active   exited  Initial cloud-init job (pre-networking)                              
  cloud-init.service                             loaded    active   exited  Initial cloud-init job (metadata service crawler)                    
● connman.service                                not-found inactive dead    connman.service                                                      
● console-screen.service                         not-found inactive dead    console-screen.service                                               
  console-setup.service                          loaded    active   exited  Set console font and keymap                                          
  containerd.service                             loaded    active   running containerd container runtime                                         
  cron.service                                   loaded    active   running Regular background program processing daemon                         
  dbus.service                                   loaded    active   running D-Bus System Message Bus                                             
● display-manager.service                        not-found inactive dead    display-manager.service                                              
  dm-event.service                               loaded    inactive dead    Device-mapper event daemon                                           
  dmesg.service                                  loaded    inactive dead    Save initial kernel messages after boot                              
  docker.service                                 loaded    active   running Docker Application Container Engine                                  
  e2scrub_all.service                            loaded    inactive dead    Online ext4 Metadata Check for All Filesystems                       
  e2scrub_reap.service                           loaded    inactive dead    Remove Stale Online ext4 Metadata Check Snapshots                    
  ec2-instance-connect.service                   loaded    inactive dead    EC2 Instance Connect Host Key Harvesting                             
  emergency.service                              loaded    inactive dead    Emergency Shell                                                      
● fcoe.service                                   not-found inactive dead    fcoe.service                                                         
  finalrd.service                                loaded    active   exited  Create final runtime dir for shutdown pivot root                     
● firewalld.service                              not-found inactive dead    firewalld.service                                                    
  fstrim.service                                 loaded    inactive dead    Discard unused blocks on filesystems from /etc/fstab                 
  fwupd-refresh.service                          loaded    inactive dead    Refresh fwupd metadata and update motd                               
  getty-static.service                           loaded    inactive dead    getty on tty2-tty6 if dbus and logind are not available              
  getty@tty1.service                             loaded    active   running Getty on tty1                                                        
  grub-common.service                            loaded    inactive dead    Record successful boot for GRUB                                      
  grub-initrd-fallback.service                   loaded    inactive dead    GRUB failed boot detection                                           
  hibinit-agent.service                          loaded    inactive dead    EC2 instance hibernation setup agent                                 
● hv_kvp_daemon.service                          not-found inactive dead    hv_kvp_daemon.service                                                
  irqbalance.service                             loaded    active   running irqbalance daemon                                                    
● iscsi-shutdown.service                         not-found inactive dead    iscsi-shutdown.service                                               
  iscsid.service                                 loaded    inactive dead    iSCSI initiator daemon (iscsid)                                      
● kbd.service                                    not-found inactive dead    kbd.service                                                          
  keyboard-setup.service                         loaded    active   exited  Set the console keyboard layout                                      
  kmod-static-nodes.service                      loaded    active   exited  Create list of static device nodes for the current kernel            
  logrotate.service                              loaded    inactive dead    Rotate log files                                                     
● lvm2-activation-early.service                  not-found inactive dead    lvm2-activation-early.service                                        
● lvm2-activation.service                        not-found inactive dead    lvm2-activation.service                                              
  lvm2-lvmpolld.service                          loaded    inactive dead    LVM2 poll daemon                                                     
  lvm2-monitor.service                           loaded    active   exited  Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progres…
  lxd-agent-9p.service                           loaded    inactive dead    LXD - agent - 9p mount                                               
  lxd-agent.service                              loaded    inactive dead    LXD - agent                                                          
  man-db.service                                 loaded    inactive dead    Daily man-db regeneration                                            
  modprobe@drm.service                           loaded    inactive dead    Load Kernel Module drm                                               
  motd-news.service                              loaded    inactive dead    Message of the Day                                                   
  multipathd.service                             loaded    active   running Device-Mapper Multipath Device Controller                            
  netplan-ovs-cleanup.service                    loaded    inactive dead    OpenVSwitch configuration for cleanup                                
  networkd-dispatcher.service                    loaded    active   running Dispatcher daemon for systemd-networkd                               
● networking.service                             not-found inactive dead    networking.service                                                   
● NetworkManager.service                         not-found inactive dead    NetworkManager.service                                               
  ondemand.service                               loaded    inactive dead    Set the CPU Frequency Scaling governor                               
  open-iscsi.service                             loaded    inactive dead    Login to default iSCSI targets                                       
  open-vm-tools.service                          loaded    inactive dead    Service for virtual machines hosted on VMware                        
● ovsdb-server.service                           not-found inactive dead    ovsdb-server.service                                                 
  plymouth-quit-wait.service                     loaded    inactive dead    Hold until boot process finishes up                                  
  plymouth-quit.service                          loaded    inactive dead    Terminate Plymouth Boot Screen                                       
  plymouth-read-write.service                    loaded    inactive dead    Tell Plymouth To Write Out Runtime Data                              
  plymouth-start.service                         loaded    inactive dead    Show Plymouth Boot Screen                                            
  polkit.service                                 loaded    active   running Authorization Manager                                                
  pollinate.service                              loaded    inactive dead    Pollinate to seed the pseudo random number generator                 
  prometheus-node-exporter.service               loaded    active   running Service that runs Prometheus Node Exporter                           
● rbdmap.service                                 not-found inactive dead    rbdmap.service                                                       
  rc-local.service                               loaded    inactive dead    /etc/rc.local Compatibility                                          
  rescue.service                                 loaded    inactive dead    Rescue Shell                                                         
  rsync.service                                  loaded    inactive dead    fast remote file copy program daemon                                 
  rsyslog.service                                loaded    active   running System Logging Service                                               
  secureboot-db.service                          loaded    inactive dead    Secure Boot updates for DB and DBX                                   
  serial-getty@ttyS0.service                     loaded    active   running Serial Getty on ttyS0                                                
  setvtrgb.service                               loaded    active   exited  Set console scheme                                                   
  snap.amazon-ssm-agent.amazon-ssm-agent.service loaded    active   running Service for snap application amazon-ssm-agent.amazon-ssm-agent       
  snap.lxd.activate.service                      loaded    inactive dead    Service for snap application lxd.activate                            
  snap.lxd.daemon.service                        loaded    inactive dead    Service for snap application lxd.daemon                              
  snapd.apparmor.service                         loaded    active   exited  Load AppArmor profiles managed internally by snapd                   
  snapd.autoimport.service                       loaded    inactive dead    Auto import assertions from block devices                            
  snapd.core-fixup.service                       loaded    inactive dead    Automatically repair incorrect owner/permissions on core devices     
  snapd.failure.service                          loaded    inactive dead    Failure handling of the snapd snap                                   
  snapd.recovery-chooser-trigger.service         loaded    inactive dead    Wait for the Ubuntu Core chooser trigger                             
  snapd.seeded.service                           loaded    active   exited  Wait until snapd is fully seeded                                     
  snapd.service                                  loaded    active   running Snap Daemon                                                          
  snapd.snap-repair.service                      loaded    inactive dead    Automatically fetch and run repair assertions                        
● ssh-keygen.service                             not-found inactive dead    ssh-keygen.service                                                   
  ssh.service                                    loaded    active   running OpenBSD Secure Shell server                                          
● sshd-keygen.service                            not-found inactive dead    sshd-keygen.service                                                  
  sysstat.service                                loaded    inactive dead    Resets System Activity Data Collector                                
  systemd-ask-password-console.service           loaded    inactive dead    Dispatch Password Requests to Console                                
  systemd-ask-password-plymouth.service          loaded    inactive dead    Forward Password Requests to Plymouth                                
  systemd-ask-password-wall.service              loaded    inactive dead    Forward Password Requests to Wall                                    
  systemd-binfmt.service                         loaded    inactive dead    Set Up Additional Binary Formats                                     
  systemd-boot-system-token.service              loaded    inactive dead    Store a System Token in an EFI Variable                              
  systemd-fsck-root.service                      loaded    active   exited  File System Check on Root Device                                     
  systemd-fsckd.service                          loaded    inactive dead    File System Check Daemon to report status                            
  systemd-hwdb-update.service                    loaded    inactive dead    Rebuild Hardware Database                                            
  systemd-initctl.service                        loaded    inactive dead    initctl Compatibility Daemon                                         
  systemd-journal-flush.service                  loaded    active   exited  Flush Journal to Persistent Storage                                  
  systemd-journald.service                       loaded    active   running Journal Service                                                      
  systemd-logind.service                         loaded    active   running Login Service                                                        
  systemd-machine-id-commit.service              loaded    active   exited  Commit a transient machine-id on disk                                
  systemd-modules-load.service                   loaded    active   exited  Load Kernel Modules                                                  
  systemd-networkd-wait-online.service           loaded    active   exited  Wait for Network to be Configured                                    
  systemd-networkd.service                       loaded    active   running Network Service                                                      
  systemd-pstore.service                         loaded    inactive dead    Platform Persistent Storage Archival                                 
  systemd-random-seed.service                    loaded    active   exited  Load/Save Random Seed                                                
  systemd-remount-fs.service                     loaded    active   exited  Remount Root and Kernel File Systems                                 
  systemd-resolved.service                       loaded    active   running Network Name Resolution                                              
  systemd-rfkill.service                         loaded    inactive dead    Load/Save RF Kill Switch Status                                      
  systemd-sysctl.service                         loaded    active   exited  Apply Kernel Variables                                               
  systemd-sysusers.service                       loaded    active   exited  Create System Users                                                  
  systemd-timesyncd.service                      loaded    active   running Network Time Synchronization                                         
  systemd-tmpfiles-clean.service                 loaded    inactive dead    Cleanup of Temporary Directories                                     
  systemd-tmpfiles-setup-dev.service             loaded    active   exited  Create Static Device Nodes in /dev                                   
  systemd-tmpfiles-setup.service                 loaded    active   exited  Create Volatile Files and Directories                                
  systemd-udev-settle.service                    loaded    active   exited  udev Wait for Complete Device Initialization                         
  systemd-udev-trigger.service                   loaded    active   exited  udev Coldplug all Devices                                            
  systemd-udevd.service                          loaded    active   running udev Kernel Device Manager                                           
● systemd-update-done.service                    not-found inactive dead    systemd-update-done.service                                          
  systemd-update-utmp-runlevel.service           loaded    inactive dead    Update UTMP about System Runlevel Changes                            
  systemd-update-utmp.service                    loaded    active   exited  Update UTMP about System Boot/Shutdown                               
  systemd-user-sessions.service                  loaded    active   exited  Permit User Sessions                                                 
● systemd-vconsole-setup.service                 not-found inactive dead    systemd-vconsole-setup.service                                       
● ua-auto-attach.service                         not-found inactive dead    ua-auto-attach.service                                               
  ua-license-check.service                       loaded    inactive dead    Poll for Ubuntu Pro licenses (Only enabled on GCP LTS non-pro)       
  ua-reboot-cmds.service                         loaded    inactive dead    Ubuntu Advantage reboot cmds                                         
  ua-timer.service                               loaded    inactive dead    Ubuntu Advantage Timer for running repeated jobs                     
  udisks2.service                                loaded    active   running Disk Manager                                                         
  unattended-upgrades.service                    loaded    active   running Unattended Upgrades Shutdown                                         
  user-runtime-dir@1000.service                  loaded    active   exited  User Runtime Directory /run/user/1000                                
  user@1000.service                              loaded    active   running User Manager for UID 1000                                            
  uuidd.service                                  loaded    inactive dead    Daemon for generating UUIDs                                          
  vgauth.service                                 loaded    inactive dead    Authentication service for virtual machines hosted on VMware         
● whoopsie.service                               not-found inactive dead    whoopsie.service                                                     
● zfs-mount.service                              not-found inactive dead    zfs-mount.service                                                    

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

142 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
root@ec2-52-205-252-202:/home/ubuntu# ls -lah /etc/systemd/system/*/ | grep  firewal
przemyslavic commented 2 years ago

:heavy_check_mark: apply -> apply